From 2d112180766dca63c1c129b0c0b755c8358191ea Mon Sep 17 00:00:00 2001 From: Jose Pablo Domingo Aramburo Sanchez Date: Thu, 9 Aug 2018 13:42:13 -0600 Subject: [PATCH 1/9] [fix] php volume --- api-payroll/Dockerfile | 10 +++++----- docker-compose.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index d4fdc8f..d107d16 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -21,20 +21,20 @@ ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 # Expose apache -EXPOSE 80 +#EXPOSE 80 # Copy this repo into place. -ADD . /var/www/site +#ADD . /var/www/site WORKDIR /var/www/site # Testing permisions -RUN chmod 777 -R . +#RUN chmod 777 -R . # Installing dependencies -RUN composer install +#RUN composer install # Unit tests -RUN composer test +#RUN composer test # Update the default apache site with the config we created. ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf diff --git a/docker-compose.yml b/docker-compose.yml index eb9029a..66e6b7a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - "8085:80" volumes: - - api-payroll:/var/www/site + - ./api-payroll:/var/www/site depends_on: - mysql mysql: From 4928481f7268d9093d8533d8fb095dd48a29eb69 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Fri, 10 Aug 2018 03:51:17 +0000 Subject: [PATCH 2/9] [add] Empty log file with permisions --- api-payroll/logs/app.log | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100755 api-payroll/logs/app.log diff --git a/api-payroll/logs/app.log b/api-payroll/logs/app.log new file mode 100755 index 0000000..e69de29 From 18ee0ad333db8e305287605c40cdda7083c6990d Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Fri, 10 Aug 2018 06:53:13 +0000 Subject: [PATCH 3/9] [add] Downloading composer dependencies --- api-payroll/Dockerfile | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index d107d16..7b1ed62 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -20,21 +20,10 @@ 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 -# Testing permisions -#RUN chmod 777 -R . - -# Installing dependencies -#RUN composer install - -# Unit tests -#RUN composer test +COPY composer.json . +RUN composer install # Update the default apache site with the config we created. ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf From 8b22c0db9c2727ff965d7c98938518b5225483a4 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 00:38:39 +0000 Subject: [PATCH 4/9] [add] Composer compileed in multi stagre --- api-payroll/Dockerfile | 16 ++++++++++++++-- docker-compose.yml | 3 --- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index 7b1ed62..480be78 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -1,3 +1,13 @@ +# Stage 1 - the build process +FROM composer:1.7.1 as build-deps +ENV COMPOSER_ALLOW_SUPERUSER 1 + +WORKDIR /root + +COPY composer.json . +RUN composer install + +# Stage 2 - the production environment FROM ubuntu:16.04 # Updating @@ -21,9 +31,11 @@ ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 WORKDIR /var/www/site +COPY . . +COPY --from=build-deps /root . -COPY composer.json . -RUN composer install +RUN touch logs/app.log +RUN chmod 777 logs/app.log # Update the default apache site with the config we created. ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf diff --git a/docker-compose.yml b/docker-compose.yml index 66e6b7a..edc24df 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,8 +5,6 @@ services: build: api-payroll/ ports: - "8085:80" - volumes: - - ./api-payroll:/var/www/site depends_on: - mysql mysql: @@ -24,5 +22,4 @@ services: MYSQL_USER: 'sloth' MYSQL_PASS: '12345678' volumes: - api-payroll: my-datavolume: From 87181696e157c5b6202d6e463241e46814a0233b Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 00:49:03 +0000 Subject: [PATCH 5/9] [add] Looks of the dockerfile --- api-payroll/Dockerfile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index 480be78..38c20a6 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -10,11 +10,22 @@ RUN composer install # 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 \ +php7.0-zip \ +curl \ +composer # Enable apache mods RUN a2enmod php7.0 @@ -37,8 +48,8 @@ COPY --from=build-deps /root . RUN touch logs/app.log RUN chmod 777 logs/app.log -# Update the default apache site with the config we created. +# Update the default apache site 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 From fee3db486fba70c94c122816aeae421b910ab12b Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 00:58:12 +0000 Subject: [PATCH 6/9] [add] Composer decoupled from prod build --- api-payroll/Dockerfile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index 38c20a6..6fab571 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -4,8 +4,9 @@ ENV COMPOSER_ALLOW_SUPERUSER 1 WORKDIR /root -COPY composer.json . +COPY . . RUN composer install +RUN composer test # Stage 2 - the production environment FROM ubuntu:16.04 @@ -22,10 +23,7 @@ php7.0-gd \ php7.0-intl \ php7.0-xml \ php7.0-mysql \ -php7.0-mcrypt \ -php7.0-zip \ -curl \ -composer +php7.0-mcrypt # Enable apache mods RUN a2enmod php7.0 @@ -42,7 +40,6 @@ ENV APACHE_LOG_DIR /var/log/apache2 ENV APACHE_LOCK_DIR /var/lock/apache2 WORKDIR /var/www/site -COPY . . COPY --from=build-deps /root . RUN touch logs/app.log From 0cdfd21fa275fa6394122849420dc3ed4a0b0d59 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 01:06:40 +0000 Subject: [PATCH 7/9] [mod] Config files moved to a directory --- api-payroll/Dockerfile | 2 +- api-payroll/{ => docker}/apache-config.conf | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename api-payroll/{ => docker}/apache-config.conf (100%) diff --git a/api-payroll/Dockerfile b/api-payroll/Dockerfile index 6fab571..a0733af 100644 --- a/api-payroll/Dockerfile +++ b/api-payroll/Dockerfile @@ -46,7 +46,7 @@ RUN touch logs/app.log RUN chmod 777 logs/app.log # Update the default apache site -ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf +ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf # 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 From f820a22a4f7fbe6374db27bf9cf9ba5d98f600e7 Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 01:25:11 +0000 Subject: [PATCH 8/9] [add] Volumes directory --- docker-compose.yml | 7 +++++-- volumes/.gitignore | 2 ++ volumes/README.md | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 volumes/.gitignore create mode 100644 volumes/README.md diff --git a/docker-compose.yml b/docker-compose.yml index edc24df..aa5a8d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,6 +5,8 @@ services: build: api-payroll/ ports: - "8085:80" + volumes: + - ./volumes/apache-logs:/var/log/apache2 depends_on: - mysql mysql: @@ -16,10 +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: - 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 From 231e7fe2e688424458da8d3bc25925eb51c6fdbc Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Sun, 12 Aug 2018 01:43:37 +0000 Subject: [PATCH 9/9] [add] Access config --- api-payroll/.htaccess | 1 + api-payroll/public/.htaccess | 2 ++ 2 files changed, 3 insertions(+) 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/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