diff --git a/api-payroll/.htaccess b/api-payroll/.htaccess index 5a928f6..42322c0 100644 --- a/api-payroll/.htaccess +++ b/api-payroll/.htaccess @@ -1 +1,2 @@ Options -Indexes +Deny from all diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index d4fdc8f..a0733af 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -1,10 +1,29 @@ +# Stage 1 - the build process +FROM composer:1.7.1 as build-deps +ENV COMPOSER_ALLOW_SUPERUSER 1 + +WORKDIR /root + +COPY . . +RUN composer install +RUN composer test + +# Stage 2 - the production environment FROM ubuntu:16.04 -# Updating RUN apt-get -y update && apt-get -y upgrade -# Installing php, apache and supplementary software -RUN apt-get -y install apache2 php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip curl git unzip composer +RUN apt-get -y install apache2 \ +php7.0 \ +libapache2-mod-php7.0 \ +php7.0-cli \ +php7.0-common \ +php7.0-mbstring \ +php7.0-gd \ +php7.0-intl \ +php7.0-xml \ +php7.0-mysql \ +php7.0-mcrypt # Enable apache mods RUN a2enmod php7.0 @@ -20,24 +39,14 @@ ENV APACHE_RUN_GROUP www-data ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 -# Expose apache -EXPOSE 80 - -# Copy this repo into place. -ADD . /var/www/site WORKDIR /var/www/site +COPY --from=build-deps /root . -# Testing permisions -RUN chmod 777 -R . +RUN touch logs/app.log +RUN chmod 777 logs/app.log -# Installing dependencies -RUN composer install +# Update the default apache site +ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf -# Unit tests -RUN composer test - -# Update the default apache site with the config we created. -ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf - -# By default start up apache in the foreground, override with /bin/bash for interative +# By default start up apache in the foreground CMD /usr/sbin/apache2ctl -D FOREGROUND diff --git a/api-payroll/apache-config.conf b/api-payroll/docker/apache-config.conf similarity index 100% rename from api-payroll/apache-config.conf rename to api-payroll/docker/apache-config.conf diff --git a/api-payroll/logs/app.log b/api-payroll/logs/app.log new file mode 100755 index 0000000..e69de29 diff --git a/api-payroll/public/.htaccess b/api-payroll/public/.htaccess index f5d1969..9b6908a 100644 --- a/api-payroll/public/.htaccess +++ b/api-payroll/public/.htaccess @@ -1,3 +1,5 @@ +allow from all + RewriteEngine On diff --git a/docker-compose.yml b/docker-compose.yml index eb9029a..aa5a8d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - "8085:80" volumes: - - api-payroll:/var/www/site + - ./volumes/apache-logs:/var/log/apache2 depends_on: - mysql mysql: @@ -18,11 +18,11 @@ services: ports: - "3307:3307" volumes: - - my-datavolume:/var/lib/mysql + - ./volumes/mysql-data:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: '12345678' MYSQL_USER: 'sloth' MYSQL_PASS: '12345678' volumes: - api-payroll: - my-datavolume: + mysql-data: + apache-logs: diff --git a/volumes/.gitignore b/volumes/.gitignore new file mode 100644 index 0000000..9e750a3 --- /dev/null +++ b/volumes/.gitignore @@ -0,0 +1,2 @@ +mysql-data/ +apache-logs/ diff --git a/volumes/README.md b/volumes/README.md new file mode 100644 index 0000000..3c5b13b --- /dev/null +++ b/volumes/README.md @@ -0,0 +1 @@ +# Do not delete this directory, it'll contain the volumes created by the containers