From 545eb291b6d32c613f814eefc8e80e39899b1e90 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Mon, 14 Oct 2019 23:36:26 +0200 Subject: Adds a docker dev setup --- docker/dev/.env | 3 ++ docker/dev/Dockerfile | 19 ++++++++++ docker/dev/docker-compose.yml | 80 +++++++++++++++++++++++++++++++++++++++++++ docker/docker-compose.yml | 20 +++++------ docker/nginx/Dockerfile | 8 +++-- docker/nginx/nginx.conf | 2 +- 6 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 docker/dev/.env create mode 100644 docker/dev/Dockerfile create mode 100644 docker/dev/docker-compose.yml (limited to 'docker') diff --git a/docker/dev/.env b/docker/dev/.env new file mode 100644 index 00000000..f1622708 --- /dev/null +++ b/docker/dev/.env @@ -0,0 +1,3 @@ +COMPOSE_PROJECT_NAME="engelsystem_dev" +UID=1000 +GID=1000 diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile new file mode 100644 index 00000000..ef514102 --- /dev/null +++ b/docker/dev/Dockerfile @@ -0,0 +1,19 @@ +# Engelsystem PHP FPM development image including Xdebug +FROM php:7-fpm-alpine AS es_php_fpm +WORKDIR /var/www +RUN apk add --no-cache icu-dev $PHPIZE_DEPS && \ + pecl install xdebug && \ + docker-php-ext-install intl pdo_mysql && \ + docker-php-ext-enable xdebug +RUN echo -e "xdebug.remote_enable=1\nxdebug.remote_connect_back=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini + +ENV TRUSTED_PROXIES 10.0.0.0/8,::ffff:10.0.0.0/8,\ + 127.0.0.0/8,::ffff:127.0.0.0/8,\ + 172.16.0.0/12,::ffff:172.16.0.0/12,\ + 192.168.0.0/16,::ffff:192.168.0.0/16,\ + ::1/128,fc00::/7,fec0::/10 + +# Engelsystem development workspace +# Contains all tools required to build / manage the system +FROM es_php_fpm AS es_workspace +RUN apk add --no-cache composer gettext nodejs npm yarn diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml new file mode 100644 index 00000000..858d6232 --- /dev/null +++ b/docker/dev/docker-compose.yml @@ -0,0 +1,80 @@ +version: "3.6" +services: + es_nginx: + image: es_dev_nginx + build: + context: ./../.. + dockerfile: docker/nginx/Dockerfile + target: es_nginx + volumes: + - ./../..:/var/www + ports: + - 5000:80 + networks: + - internal + depends_on: + - es_php_fpm + es_php_fpm: + image: es_dev_php_fpm + build: + context: ./../.. + dockerfile: docker/dev/Dockerfile + target: es_php_fpm + user: "${UID}:${GID}" + volumes: + - ./../..:/var/www + environment: + MYSQL_HOST: es_database + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_DATABASE: engelsystem + PHP_IDE_CONFIG: serverName=engelsystem + ENVIRONMENT: development + MAIL_DRIVER: log + APP_NAME: Engelsystem DEV + networks: + - internal + - database + depends_on: + - es_database + es_workspace: + image: es_dev_workspace + build: + context: ./../.. + dockerfile: docker/dev/Dockerfile + target: es_workspace + user: "${UID}:${GID}" + volumes: + - ./../..:/var/www + environment: + HOME: /tmp + MYSQL_HOST: es_database + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_DATABASE: engelsystem + ENVIRONMENT: development + MAIL_DRIVER: log + APP_NAME: Engelsystem DEV + networks: + - internal + - database + depends_on: + - es_database + es_database: + image: mariadb:10.2 + environment: + MYSQL_DATABASE: engelsystem + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_RANDOM_ROOT_PASSWORD: 1 + MYSQL_INITDB_SKIP_TZINFO: "yes" + volumes: + - db:/var/lib/mysql + networks: + - database +volumes: + db: {} + +networks: + internal: + database: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f4be4eb2..47b85d56 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,23 +1,23 @@ version: "3.6" services: - nginx: - image: engelsystem-nginx + es_nginx: + image: es_nginx build: context: .. - dockerfile: "" + dockerfile: docker/nginx/Dockerfile ports: - 5000:80 networks: - internal depends_on: - - engelsystem - engelsystem: - image: engelsystem + - es_php_fpm + es_php_fpm: + image: es_php_fpm build: context: .. - dockerfile: "" + dockerfile: docker/Dockerfile environment: - MYSQL_HOST: database + MYSQL_HOST: es_database MYSQL_USER: engelsystem MYSQL_PASSWORD: engelsystem MYSQL_DATABASE: engelsystem @@ -25,8 +25,8 @@ services: - internal - database depends_on: - - database - database: + - es_database + es_database: image: mariadb:10.2 environment: MYSQL_DATABASE: engelsystem diff --git a/docker/nginx/Dockerfile b/docker/nginx/Dockerfile index 47b3d50e..f4355af9 100644 --- a/docker/nginx/Dockerfile +++ b/docker/nginx/Dockerfile @@ -1,3 +1,7 @@ +FROM nginx:alpine as es_nginx +RUN mkdir -p /var/www/public/ && touch /var/www/public/index.php +COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf + FROM node:10-alpine as themes WORKDIR /app COPY .babelrc .browserslistrc package.json webpack.config.js yarn.lock /app/ @@ -5,7 +9,5 @@ RUN yarn install COPY resources/assets/ /app/resources/assets RUN yarn build -FROM nginx:alpine -RUN mkdir -p /var/www/public/ && touch /var/www/public/index.php -COPY docker/nginx/nginx.conf /etc/nginx/nginx.conf +FROM es_nginx COPY --from=themes /app/public/assets /var/www/public/assets/ diff --git a/docker/nginx/nginx.conf b/docker/nginx/nginx.conf index d95c18e2..63e934bc 100644 --- a/docker/nginx/nginx.conf +++ b/docker/nginx/nginx.conf @@ -33,7 +33,7 @@ http { } location ~ \.php$ { - fastcgi_pass engelsystem:9000; + fastcgi_pass es_php_fpm:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; -- cgit v1.2.3-54-g00ecf