From 94858ec2e15109a62707f784a2bc0ca63d58cf8b Mon Sep 17 00:00:00 2001 From: Alexis Saettler Date: Thu, 21 May 2020 15:22:29 +0200 Subject: [PATCH] feat: update templates (#19) --- .examples/maxsize/app/Dockerfile | 3 ++ .examples/maxsize/docker-compose.yml | 2 ++ .../app/Dockerfile | 4 +++ .../docker-compose.yml | 10 +++++-- .examples/nginx-proxy/app/Dockerfile | 4 +++ .examples/nginx-proxy/docker-compose.yml | 10 +++++-- .examples/supervisor/apache/app/Dockerfile | 4 +++ .../supervisor/apache/docker-compose.yml | 1 + .../supervisor/fpm-alpine/app/Dockerfile | 4 +++ .examples/supervisor/fpm/app/Dockerfile | 4 +++ .templates/Dockerfile-apache.template | 15 ++++++++-- .templates/Dockerfile-install.template | 6 +--- .templates/Dockerfile-label.template | 2 +- Dockerfile-debian.template | 7 +---- apache/Dockerfile | 30 ++++++++++--------- fpm-alpine/Dockerfile | 8 ++--- fpm/Dockerfile | 15 ++-------- 17 files changed, 77 insertions(+), 52 deletions(-) create mode 100644 .examples/nginx-proxy-self-signed-ssl/app/Dockerfile create mode 100644 .examples/nginx-proxy/app/Dockerfile diff --git a/.examples/maxsize/app/Dockerfile b/.examples/maxsize/app/Dockerfile index ed26493..47c3db8 100644 --- a/.examples/maxsize/app/Dockerfile +++ b/.examples/maxsize/app/Dockerfile @@ -1,5 +1,8 @@ FROM monica:fpm-alpine +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + RUN set -ex;\ \ { \ diff --git a/.examples/maxsize/docker-compose.yml b/.examples/maxsize/docker-compose.yml index 9b42a6c..1c4347f 100644 --- a/.examples/maxsize/docker-compose.yml +++ b/.examples/maxsize/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.4" services: app: build: ./app + image: monica-app depends_on: - db env_file: .env @@ -15,6 +16,7 @@ services: web: build: ./web + image: monica-web restart: always ports: - 8881:80 diff --git a/.examples/nginx-proxy-self-signed-ssl/app/Dockerfile b/.examples/nginx-proxy-self-signed-ssl/app/Dockerfile new file mode 100644 index 0000000..0201286 --- /dev/null +++ b/.examples/nginx-proxy-self-signed-ssl/app/Dockerfile @@ -0,0 +1,4 @@ +FROM monica:fpm + +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" diff --git a/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml b/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml index c10b87c..34a5e2c 100644 --- a/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml +++ b/.examples/nginx-proxy-self-signed-ssl/docker-compose.yml @@ -22,7 +22,8 @@ version: "3.4" services: app: - image: monica:fpm + build: ./app + image: monica-app env_file: .env volumes: - data:/var/www/html/storage @@ -47,7 +48,8 @@ services: restart: always cron: - image: monica:fpm + build: ./app + image: monica-app env_file: .env restart: always volumes: @@ -58,7 +60,8 @@ services: - redis queue: - image: monica:fpm + build: ./app + image: monica-app env_file: .env restart: always volumes: @@ -70,6 +73,7 @@ services: web: build: ./web + image: monica-web restart: always environment: - VIRTUAL_HOST=monica.local diff --git a/.examples/nginx-proxy/app/Dockerfile b/.examples/nginx-proxy/app/Dockerfile new file mode 100644 index 0000000..0201286 --- /dev/null +++ b/.examples/nginx-proxy/app/Dockerfile @@ -0,0 +1,4 @@ +FROM monica:fpm + +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" diff --git a/.examples/nginx-proxy/docker-compose.yml b/.examples/nginx-proxy/docker-compose.yml index 5fc55ca..2c287b8 100644 --- a/.examples/nginx-proxy/docker-compose.yml +++ b/.examples/nginx-proxy/docker-compose.yml @@ -21,7 +21,8 @@ version: "3.4" services: app: - image: monica:fpm + build: ./app + image: monica-app env_file: .env volumes: - data:/var/www/html/storage @@ -46,7 +47,8 @@ services: restart: always cron: - image: monica:fpm + build: ./app + image: monica-app env_file: .env restart: always volumes: @@ -57,7 +59,8 @@ services: - redis queue: - image: monica:fpm + build: ./app + image: monica-app env_file: .env restart: always volumes: @@ -69,6 +72,7 @@ services: web: build: ./web + image: monica-web restart: always environment: - VIRTUAL_HOST= diff --git a/.examples/supervisor/apache/app/Dockerfile b/.examples/supervisor/apache/app/Dockerfile index 590187e..05035f6 100644 --- a/.examples/supervisor/apache/app/Dockerfile +++ b/.examples/supervisor/apache/app/Dockerfile @@ -1,5 +1,8 @@ FROM monica:apache +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + # supervisord dependencies RUN set -ex; \ \ @@ -10,4 +13,5 @@ RUN set -ex; \ rm -rf /var/lib/apt/lists/* COPY supervisord.conf /etc/supervisord.conf + CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/.examples/supervisor/apache/docker-compose.yml b/.examples/supervisor/apache/docker-compose.yml index 4ebfa68..1626e36 100644 --- a/.examples/supervisor/apache/docker-compose.yml +++ b/.examples/supervisor/apache/docker-compose.yml @@ -3,6 +3,7 @@ version: "3.4" services: app: build: ./app + image: monica-app depends_on: - db env_file: .env diff --git a/.examples/supervisor/fpm-alpine/app/Dockerfile b/.examples/supervisor/fpm-alpine/app/Dockerfile index 37e0091..8729565 100644 --- a/.examples/supervisor/fpm-alpine/app/Dockerfile +++ b/.examples/supervisor/fpm-alpine/app/Dockerfile @@ -1,5 +1,8 @@ FROM monica:fpm-alpine +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + # supervisord dependencies RUN set -ex; \ \ @@ -8,4 +11,5 @@ RUN set -ex; \ ; COPY supervisord.conf /etc/supervisord.conf + CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/.examples/supervisor/fpm/app/Dockerfile b/.examples/supervisor/fpm/app/Dockerfile index ed7ddc1..230106a 100644 --- a/.examples/supervisor/fpm/app/Dockerfile +++ b/.examples/supervisor/fpm/app/Dockerfile @@ -1,5 +1,8 @@ FROM monica:fpm +# Use the default production configuration +RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" + # supervisord dependencies RUN set -ex; \ \ @@ -10,4 +13,5 @@ RUN set -ex; \ rm -rf /var/lib/apt/lists/* COPY supervisord.conf /etc/supervisord.conf + CMD ["supervisord", "-c", "/etc/supervisord.conf"] diff --git a/.templates/Dockerfile-apache.template b/.templates/Dockerfile-apache.template index 2436ca0..e974054 100644 --- a/.templates/Dockerfile-apache.template +++ b/.templates/Dockerfile-apache.template @@ -1,5 +1,16 @@ +RUN set -ex; \ + \ + a2enmod headers rewrite remoteip; \ + { \ + echo RemoteIPHeader X-Real-IP; \ + echo RemoteIPTrustedProxy 10.0.0.0/8; \ + echo RemoteIPTrustedProxy 172.16.0.0/12; \ + echo RemoteIPTrustedProxy 192.168.0.0/16; \ + } > $APACHE_CONFDIR/conf-available/remoteip.conf; \ + a2enconf remoteip + ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN set -ex; \ \ - sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/sites-available/*.conf; \ - sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" $APACHE_CONFDIR/sites-available/*.conf; \ + sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" $APACHE_CONFDIR/apache2.conf $APACHE_CONFDIR/conf-available/*.conf diff --git a/.templates/Dockerfile-install.template b/.templates/Dockerfile-install.template index 21779a3..7bc3b9e 100644 --- a/.templates/Dockerfile-install.template +++ b/.templates/Dockerfile-install.template @@ -4,11 +4,7 @@ \ GPGKEY='BDAB0D0D36A00466A2964E85DE15667131EA6018'; \ export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keys.gnupg.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY"; \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY"; \ gpg --batch --verify monica-${MONICA_VERSION}.tar.bz2.asc monica-${MONICA_VERSION}.tar.bz2; \ \ tar -xf monica-${MONICA_VERSION}.tar.bz2 -C /var/www/html --strip-components=1; \ diff --git a/.templates/Dockerfile-label.template b/.templates/Dockerfile-label.template index e6fea39..a2ba582 100644 --- a/.templates/Dockerfile-label.template +++ b/.templates/Dockerfile-label.template @@ -2,7 +2,7 @@ LABEL org.opencontainers.image.authors="Alexis Saettler " \ org.opencontainers.image.title="MonicaHQ, the Personal Relationship Manager" \ org.opencontainers.image.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \ org.opencontainers.image.url="https://monicahq.com" \ - org.opencontainers.image.revision="%%COMMIT%%" \ + org.opencontainers.image.revision="%%COMMIT%%" \ org.opencontainers.image.source="https://github.com/monicahq/docker" \ org.opencontainers.image.vendor="Monica" \ org.opencontainers.image.version="%%VERSION%%" diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index b904855..e80ceba 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -73,12 +73,7 @@ RUN set -ex; \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/*; \ - \ - if command -v a2enmod; then \ - a2enmod rewrite; \ - fi - + rm -rf /var/lib/apt/lists/* %%EXTRA_INSTALL%% diff --git a/apache/Dockerfile b/apache/Dockerfile index 6173564..f4dcdd4 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -5,7 +5,7 @@ LABEL org.opencontainers.image.authors="Alexis Saettler " \ org.opencontainers.image.title="MonicaHQ, the Personal Relationship Manager" \ org.opencontainers.image.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \ org.opencontainers.image.url="https://monicahq.com" \ - org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ + org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ org.opencontainers.image.source="https://github.com/monicahq/docker" \ org.opencontainers.image.vendor="Monica" \ org.opencontainers.image.version="v2.17.0" @@ -83,12 +83,7 @@ RUN set -ex; \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/*; \ - \ - if command -v a2enmod; then \ - a2enmod rewrite; \ - fi - + rm -rf /var/lib/apt/lists/* # Set crontab for schedules RUN set -ex; \ @@ -120,11 +115,22 @@ RUN set -ex; \ \ echo 'memory_limit=512M' > $PHP_INI_DIR/conf.d/memory-limit.ini +RUN set -ex; \ + \ + a2enmod headers rewrite remoteip; \ + { \ + echo RemoteIPHeader X-Real-IP; \ + echo RemoteIPTrustedProxy 10.0.0.0/8; \ + echo RemoteIPTrustedProxy 172.16.0.0/12; \ + echo RemoteIPTrustedProxy 192.168.0.0/16; \ + } > $APACHE_CONFDIR/conf-available/remoteip.conf; \ + a2enconf remoteip + ENV APACHE_DOCUMENT_ROOT /var/www/html/public RUN set -ex; \ \ - sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/sites-available/*.conf; \ - sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf + sed -ri -e "s!/var/www/html!${APACHE_DOCUMENT_ROOT}!g" $APACHE_CONFDIR/sites-available/*.conf; \ + sed -ri -e "s!/var/www/!${APACHE_DOCUMENT_ROOT}!g" $APACHE_CONFDIR/apache2.conf $APACHE_CONFDIR/conf-available/*.conf WORKDIR /var/www/html @@ -144,11 +150,7 @@ RUN set -ex; \ \ GPGKEY='BDAB0D0D36A00466A2964E85DE15667131EA6018'; \ export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keys.gnupg.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY"; \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY"; \ gpg --batch --verify monica-${MONICA_VERSION}.tar.bz2.asc monica-${MONICA_VERSION}.tar.bz2; \ \ tar -xf monica-${MONICA_VERSION}.tar.bz2 -C /var/www/html --strip-components=1; \ diff --git a/fpm-alpine/Dockerfile b/fpm-alpine/Dockerfile index 65f9c54..bd71436 100644 --- a/fpm-alpine/Dockerfile +++ b/fpm-alpine/Dockerfile @@ -5,7 +5,7 @@ LABEL org.opencontainers.image.authors="Alexis Saettler " \ org.opencontainers.image.title="MonicaHQ, the Personal Relationship Manager" \ org.opencontainers.image.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \ org.opencontainers.image.url="https://monicahq.com" \ - org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ + org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ org.opencontainers.image.source="https://github.com/monicahq/docker" \ org.opencontainers.image.vendor="Monica" \ org.opencontainers.image.version="v2.17.0" @@ -127,11 +127,7 @@ RUN set -ex; \ \ GPGKEY='BDAB0D0D36A00466A2964E85DE15667131EA6018'; \ export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keys.gnupg.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY"; \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY"; \ gpg --batch --verify monica-${MONICA_VERSION}.tar.bz2.asc monica-${MONICA_VERSION}.tar.bz2; \ \ tar -xf monica-${MONICA_VERSION}.tar.bz2 -C /var/www/html --strip-components=1; \ diff --git a/fpm/Dockerfile b/fpm/Dockerfile index a2ff31a..8c0e947 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -5,7 +5,7 @@ LABEL org.opencontainers.image.authors="Alexis Saettler " \ org.opencontainers.image.title="MonicaHQ, the Personal Relationship Manager" \ org.opencontainers.image.description="This is MonicaHQ, your personal memory! MonicaHQ is like a CRM but for the friends, family, and acquaintances around you." \ org.opencontainers.image.url="https://monicahq.com" \ - org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ + org.opencontainers.image.revision="3a1243d3195668171b8d096c0f903c08513336d9" \ org.opencontainers.image.source="https://github.com/monicahq/docker" \ org.opencontainers.image.vendor="Monica" \ org.opencontainers.image.version="v2.17.0" @@ -83,12 +83,7 @@ RUN set -ex; \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/*; \ - \ - if command -v a2enmod; then \ - a2enmod rewrite; \ - fi - + rm -rf /var/lib/apt/lists/* # Set crontab for schedules RUN set -ex; \ @@ -140,11 +135,7 @@ RUN set -ex; \ \ GPGKEY='BDAB0D0D36A00466A2964E85DE15667131EA6018'; \ export GNUPGHOME="$(mktemp -d)"; \ - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver ipv4.pool.sks-keyservers.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keys.gnupg.net --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver pgp.mit.edu --recv-keys "$GPGKEY" \ - || gpg --batch --keyserver keyserver.pgp.com --recv-keys "$GPGKEY"; \ + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPGKEY"; \ gpg --batch --verify monica-${MONICA_VERSION}.tar.bz2.asc monica-${MONICA_VERSION}.tar.bz2; \ \ tar -xf monica-${MONICA_VERSION}.tar.bz2 -C /var/www/html --strip-components=1; \