From 90f80facb2384082ad95dad3736d462a8b5bc04d Mon Sep 17 00:00:00 2001 From: GotPPay Date: Tue, 19 Jun 2018 05:10:21 +0200 Subject: [PATCH] seperate frontend and backend into different containers --- backend.dockerfile | 10 +++++++++ docker-compose.yml | 18 ++++++++++----- docker/php/backend.conf | 32 --------------------------- docker/php/frontend.conf | 32 --------------------------- web.dockerfile => frontend.dockerfile | 9 -------- 5 files changed, 23 insertions(+), 78 deletions(-) create mode 100644 backend.dockerfile delete mode 100644 docker/php/backend.conf delete mode 100644 docker/php/frontend.conf rename web.dockerfile => frontend.dockerfile (73%) diff --git a/backend.dockerfile b/backend.dockerfile new file mode 100644 index 0000000..dd21e04 --- /dev/null +++ b/backend.dockerfile @@ -0,0 +1,10 @@ +FROM php:7.0-apache + +RUN docker-php-ext-install pdo pdo_mysql mysqli +RUN a2enmod rewrite + +COPY docker/php/apache2.conf /etc/apache2/ + +COPY backend /var/www/html + +RUN chown -R www-data:www-data /var/www/html diff --git a/docker-compose.yml b/docker-compose.yml index 6ec54ce..2aad039 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,20 +1,28 @@ version : '2' services: - web: + backend: build: context: . - dockerfile: web.dockerfile + dockerfile: backend.dockerfile volumes: - - ./log/web/:/var/log/apache2/ + - ./log/backend/:/var/log/apache2/ ports: - - '8080:80' - - '8081:443' + - '8081:80' depends_on: - db #use links keywoard to use db as a known host "db" to connect to database links: - db + + frontend: + build: + context: . + dockerfile: frontend.dockerfile + volumens: + - ./log/frontend/:/var/log/apache2/ + ports: + - '8080:80' db: build: diff --git a/docker/php/backend.conf b/docker/php/backend.conf deleted file mode 100644 index 2746f47..0000000 --- a/docker/php/backend.conf +++ /dev/null @@ -1,32 +0,0 @@ - - # The ServerName directive sets the request scheme, hostname and port that - # the server uses to identify itself. This is used when creating - # redirection URLs. In the context of virtual hosts, the ServerName - # specifies what hostname must appear in the request's Host: header to - # match this virtual host. For the default virtual host (this file) this - # value is not decisive as it is used as a last resort host regardless. - # However, you must set it for any further virtual host explicitly. - - ServerName localhost:8080/api-wiaas - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/backend - - # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, - # error, crit, alert, emerg. - # It is also possible to configure the loglevel for particular - # modules, e.g. - #LogLevel info ssl:warn - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - # For most configuration files from conf-available/, which are - # enabled or disabled at a global level, it is possible to - # include a line for only one particular virtual host. For example the - # following line enables the CGI configuration for this host only - # after it has been globally disabled with "a2disconf". - #Include conf-available/serve-cgi-bin.conf - - -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/docker/php/frontend.conf b/docker/php/frontend.conf deleted file mode 100644 index 98ddf44..0000000 --- a/docker/php/frontend.conf +++ /dev/null @@ -1,32 +0,0 @@ - - # The ServerName directive sets the request scheme, hostname and port that - # the server uses to identify itself. This is used when creating - # redirection URLs. In the context of virtual hosts, the ServerName - # specifies what hostname must appear in the request's Host: header to - # match this virtual host. For the default virtual host (this file) this - # value is not decisive as it is used as a last resort host regardless. - # However, you must set it for any further virtual host explicitly. - - ServerName localhost:8080 - - ServerAdmin webmaster@localhost - DocumentRoot /var/www/html - - # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, - # error, crit, alert, emerg. - # It is also possible to configure the loglevel for particular - # modules, e.g. - #LogLevel info ssl:warn - - ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined - - # For most configuration files from conf-available/, which are - # enabled or disabled at a global level, it is possible to - # include a line for only one particular virtual host. For example the - # following line enables the CGI configuration for this host only - # after it has been globally disabled with "a2disconf". - #Include conf-available/serve-cgi-bin.conf - - -# vim: syntax=apache ts=4 sw=4 sts=4 sr noet diff --git a/web.dockerfile b/frontend.dockerfile similarity index 73% rename from web.dockerfile rename to frontend.dockerfile index deae637..1cae917 100644 --- a/web.dockerfile +++ b/frontend.dockerfile @@ -8,15 +8,6 @@ RUN apt-get update && apt-get install -y git unzip gnupg RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - RUN apt-get install -y nodejs -RUN docker-php-ext-install pdo pdo_mysql mysqli -RUN a2enmod rewrite - -COPY docker/php/apache2.conf /etc/apache2/ - -COPY backend /var/www/html - -RUN chown -R www-data:www-data /var/www/html - COPY frontend /home/wiaas/frontend WORKDIR /home/wiaas/frontend