Skip to content

Commit

Permalink
Improve image size / Update mailserver-admin and php
Browse files Browse the repository at this point in the history
feat: Improved web image size (fixes jeboehm#98)
feat: Update to mailserver-admin 2.0.3 / PHP 8 (jeboehm#156)
  • Loading branch information
jeboehm authored Apr 29, 2022
1 parent 3858afb commit a950714
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
31 changes: 24 additions & 7 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM jwilder/dockerize:0.6.1 AS dockerize
FROM roundcube/roundcubemail:1.5.x-fpm AS roundcube
FROM jeboehm/php-nginx-base:7.4
FROM composer:2.3 AS composer
FROM php:8.0-fpm-alpine

ARG ADMIN_VER=1.6.4
ARG ADMIN_VER=2.0.3

LABEL maintainer="[email protected]"
LABEL vendor="https://github.com/jeboehm/docker-mailserver"
Expand All @@ -20,21 +21,37 @@ ENV MYSQL_HOST=db \
APP_ENV=prod \
TRUSTED_PROXIES=172.16.0.0/12 \
WAITSTART_TIMEOUT=1m \
ADMIN_VER=${ADMIN_VER}
ADMIN_VER=${ADMIN_VER} \
DATABASE_URL="mysql://%env(MYSQL_USER)%:%env(MYSQL_PASSWORD)%@%env(MYSQL_HOST)%:3306/%env(MYSQL_DATABASE)%?serverVersion=mariadb-10.4.11"

COPY --from=roundcube /usr/src/roundcubemail/ /var/www/html/webmail/
COPY --from=dockerize /usr/local/bin/dockerize /usr/local/bin
COPY --from=composer /usr/bin/composer /usr/bin/composer

RUN apk add --no-cache \
icu \
icu-dev \
nginx \
supervisor && \
docker-php-ext-install -j5 \
intl \
opcache \
pdo_mysql && \
ln -sf /dev/stdout /var/log/nginx/access.log && \
ln -sf /dev/stderr /var/log/nginx/error.log && \
apk del --no-cache icu-dev

COPY rootfs/ /

WORKDIR /opt/manager

RUN wget -O /tmp/admin.tar.gz -q https://github.com/jeboehm/mailserver-admin/archive/${ADMIN_VER}.tar.gz && \
tar -xf /tmp/admin.tar.gz -C /opt/manager --strip=1 && \
rm /tmp/admin.tar.gz && \
composer install --no-dev -o && \
rm -f /etc/nginx/conf.d/realip.conf

RUN ln -s /opt/manager/public /var/www/html/manager && \
composer install --no-dev --prefer-dist -o --apcu-autoloader && \
bin/console cache:clear --no-warmup --env=prod && \
bin/console cache:warmup --env=prod && \
ln -s /opt/manager/public /var/www/html/manager && \
chown -R www-data \
/opt/manager/var/cache/ \
/opt/manager/var/log/ \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ server {
client_max_body_size 24M;
client_body_buffer_size 128k;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php-fpm;
fastcgi_pass 127.0.0.1:9000;
}
}

Expand All @@ -52,7 +52,7 @@ server {
}

location ~ ^/index\.php(/|$) {
fastcgi_pass php-fpm;
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
Expand Down
18 changes: 18 additions & 0 deletions web/rootfs/etc/supervisord.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[supervisord]
nodaemon=true
logfile=/dev/stderr
logfile_maxbytes=0
pidfile=/run/supervisord.pid
user=root

[program:php-fpm]
command=/usr/local/sbin/php-fpm
redirect_stderr=true
stdout_logfile=/dev/stderr
stdout_logfile_maxbytes=0

[program:nginx]
command=/usr/sbin/nginx -g "daemon off; pid off;"
redirect_stderr=true
stdout_logfile=/dev/stderr
stdout_logfile_maxbytes=0
6 changes: 4 additions & 2 deletions web/rootfs/usr/local/bin/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ dockerize \
-wait tcp://${FILTER_HOST}:11334 \
-wait file:///media/dkim/ \
-timeout ${WAITSTART_TIMEOUT} \
-template /etc/nginx/10-docker.conf.templ:/etc/nginx/sites-enabled/10-docker.conf
-template /etc/nginx/http.d/default.conf.templ:/etc/nginx/http.d/default.conf

manager_init
roundcube_init
permissions
dkim_refresh

/usr/bin/supervisord
export APP_SECRET=`echo $RANDOM | md5sum | head -c 20`

/usr/bin/supervisord -c /etc/supervisord.conf
9 changes: 9 additions & 0 deletions web/rootfs/usr/local/etc/php/conf.d/zzz_app.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
opcache.memory_consumption = 256
opcache.max_accelerated_files = 20000
opcache.validate_timestamps = 0

realpath_cache_size = 4096K
realpath_cache_ttl = 600

expose_php = Off
display_errors = Off

0 comments on commit a950714

Please sign in to comment.