diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/Dockerfile | 44 | ||||
-rw-r--r-- | contrib/docker-compose.yml | 46 | ||||
-rw-r--r-- | contrib/nginx/Dockerfile | 12 | ||||
-rw-r--r-- | contrib/nginx/nginx.conf | 42 |
4 files changed, 144 insertions, 0 deletions
diff --git a/contrib/Dockerfile b/contrib/Dockerfile new file mode 100644 index 00000000..665fb426 --- /dev/null +++ b/contrib/Dockerfile @@ -0,0 +1,44 @@ +# Setup +ARG NGINX_IMAGE=engelsystem-nginx:latest + +# composer install +FROM composer AS composer +COPY composer.json /app/ +RUN composer --no-ansi install --no-dev --ignore-platform-reqs +RUN composer --no-ansi dump-autoload --optimize + +# Use frontend container for assets +FROM ${NGINX_IMAGE} AS frontend + +# Intermediate container for less layers +FROM alpine as data +COPY bin/ /app/bin +COPY config/ /app/config +COPY db/ /app/db +COPY includes/ /app/includes +COPY public/ /app/public +COPY --from=frontend /var/www/public/assets/ /app/public/assets +COPY resources/lang /app/resources/lang +COPY resources/views /app/resources/views +COPY src/ /app/src + +COPY composer.json LICENSE package.json README.md /app/ + +COPY --from=composer /app/vendor/ /app/vendor +COPY --from=composer /app/composer.lock /app/ + +RUN rm -f /app/config/config.php + +# Build the PHP container +FROM php:7-fpm-alpine +WORKDIR /var/www +COPY --from=data /app/ /var/www +RUN apk add --no-cache icu-dev gettext-dev && \ + docker-php-ext-install intl gettext pdo_mysql && \ + rm -r /var/www/html + +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/contrib/docker-compose.yml b/contrib/docker-compose.yml new file mode 100644 index 00000000..b1dab793 --- /dev/null +++ b/contrib/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3.6" +services: + nginx: + image: engelsystem-nginx + build: + context: .. + dockerfile: contrib/nginx/Dockerfile + ports: + - 5000:80 + networks: + - internal + depends_on: + - engelsystem + engelsystem: + image: engelsystem + build: + context: .. + dockerfile: contrib/Dockerfile + environment: + MYSQL_HOST: database + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_DATABASE: engelsystem + networks: + - internal + - database + depends_on: + - database + database: + image: mariadb:latest + environment: + MYSQL_DATABASE: engelsystem + MYSQL_USER: engelsystem + MYSQL_PASSWORD: engelsystem + MYSQL_RANDOM_ROOT_PASSWORD: 1 + volumes: + - db:/var/lib/mysql + networks: + - database +volumes: + db: {} + static: {} + +networks: + internal: + database: diff --git a/contrib/nginx/Dockerfile b/contrib/nginx/Dockerfile new file mode 100644 index 00000000..e838d368 --- /dev/null +++ b/contrib/nginx/Dockerfile @@ -0,0 +1,12 @@ +FROM node:8-alpine as themes +WORKDIR /app +COPY resources/assets/ /app/resources/assets +COPY .babelrc package.json webpack.config.js /app/ +RUN apk add --no-cache yarn +RUN yarn install +RUN yarn build + +FROM nginx:alpine +COPY contrib/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=themes /app/public/assets /var/www/public/assets/ +RUN touch /var/www/public/index.php diff --git a/contrib/nginx/nginx.conf b/contrib/nginx/nginx.conf new file mode 100644 index 00000000..d95c18e2 --- /dev/null +++ b/contrib/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 engelsystem:9000; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + } +} |