diff options
Diffstat (limited to 'docker')
-rw-r--r-- | docker/.env | 1 | ||||
-rw-r--r-- | docker/Dockerfile | 48 | ||||
-rw-r--r-- | docker/dev/.env | 3 | ||||
-rw-r--r-- | docker/dev/Dockerfile | 19 | ||||
-rw-r--r-- | docker/dev/docker-compose.yml | 80 | ||||
-rw-r--r-- | docker/docker-compose.yml | 46 | ||||
-rw-r--r-- | docker/nginx/Dockerfile | 13 | ||||
-rw-r--r-- | docker/nginx/nginx.conf | 42 |
8 files changed, 252 insertions, 0 deletions
diff --git a/docker/.env b/docker/.env new file mode 100644 index 00000000..5f8d43b8 --- /dev/null +++ b/docker/.env @@ -0,0 +1 @@ +COMPOSE_PROJECT_NAME="engelsystem" diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..013ccf1d --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,48 @@ +# composer install +FROM composer AS composer +COPY ./ /app/ +RUN composer --no-ansi install --no-dev --ignore-platform-reqs +RUN composer --no-ansi dump-autoload --optimize + +# Intermediate containers for less layers +FROM alpine as translation +RUN apk add gettext +COPY resources/lang/ /data +RUN find /data -type f -name '*.po' -exec sh -c 'file="{}"; msgfmt "${file%.*}.po" -o "${file%.*}.mo"' \; + +FROM alpine as data +COPY .babelrc .browserslistrc composer.json LICENSE package.json README.md webpack.config.js yarn.lock /app/ +COPY bin/ /app/bin +COPY config/ /app/config +COPY db/ /app/db +RUN mkdir /app/import/ +COPY includes/ /app/includes +COPY public/ /app/public +COPY resources/views /app/resources/views +COPY src/ /app/src +COPY storage/ /app/storage + +COPY --from=translation /data/ /app/resources/lang +COPY --from=composer /app/vendor/ /app/vendor +COPY --from=composer /app/composer.lock /app/ + +RUN find /app/storage/ -type f -not -name .gitignore -exec rm {} \; +RUN rm -f /app/config/config.php + +# Build the PHP container +FROM php:7-fpm-alpine +WORKDIR /var/www +RUN apk add --no-cache icu-dev && \ + docker-php-ext-install intl pdo_mysql +COPY --from=data /app/ /var/www +RUN chown -R www-data:www-data /var/www/import/ /var/www/storage/ && \ + rm -r /var/www/html + +ARG VERSION +RUN if [[ ! -f /var/www/storage/app/VERSION ]] && [[ ! -z "${VERSION}" ]]; then echo -n "${VERSION}" > /var/www/storage/app/VERSION; fi + +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 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 new file mode 100644 index 00000000..47b85d56 --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3.6" +services: + es_nginx: + image: es_nginx + build: + context: .. + dockerfile: docker/nginx/Dockerfile + ports: + - 5000:80 + networks: + - internal + depends_on: + - es_php_fpm + es_php_fpm: + image: es_php_fpm + build: + context: .. + dockerfile: docker/Dockerfile + environment: + MYSQL_HOST: es_database + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_DATABASE: engelsystem + 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/nginx/Dockerfile b/docker/nginx/Dockerfile new file mode 100644 index 00000000..f4355af9 --- /dev/null +++ b/docker/nginx/Dockerfile @@ -0,0 +1,13 @@ +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/ +RUN yarn install +COPY resources/assets/ /app/resources/assets +RUN yarn build + +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 new file mode 100644 index 00000000..63e934bc --- /dev/null +++ b/docker/nginx/nginx.conf @@ -0,0 +1,42 @@ +error_log stderr; + +events { + worker_connections 1024; +} + +http { + client_body_temp_path /tmp/client_body_temp; + fastcgi_temp_path /tmp/fastcgi_temp; + proxy_temp_path /tmp/proxy_temp; + scgi_temp_path /tmp/scgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + + map $http_x_forwarded_proto $forwarded_proto { + default $http_x_forwarded_proto; + https https; + } + + server { + include mime.types; + access_log off; + listen [::]:80 ipv6only=off; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $forwarded_proto; + index index.php; + root /var/www/public; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + fastcgi_pass es_php_fpm:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + } +} |