From 8bbdbd6fa7a2d991275de9160b5d51f5ca2b5164 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 3 May 2023 16:31:32 +0200 Subject: [PATCH 1/3] optimze mastercontainer Dockerfile Signed-off-by: Zoey --- Containers/mastercontainer/Dockerfile | 100 +++++++++++--------------- 1 file changed, 41 insertions(+), 59 deletions(-) diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index 5f0a765e..5c4312b3 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -7,22 +7,24 @@ FROM caddy:2.6.4-alpine as caddy # From https://github.com/docker-library/php/blob/master/8.1/alpine3.17/fpm/Dockerfile FROM php:8.1.18-fpm-alpine3.17 +EXPOSE 80 +EXPOSE 8080 +EXPOSE 8443 + +COPY mastercontainer.conf /etc/apache2/sites-available/mastercontainer.conf + +COPY --from=caddy /usr/bin/caddy /usr/bin/caddy +COPY --from=docker /usr/local/bin/docker /usr/local/bin/docker + +WORKDIR /var/www/docker-aio + RUN set -ex; \ apk add --no-cache shadow; \ groupmod -g 333 xfs; \ usermod -u 333 -g 333 xfs; \ groupmod -g 33 www-data; \ - usermod -u 33 -g 33 www-data - -EXPOSE 80 -EXPOSE 8080 -EXPOSE 8443 - -RUN mkdir -p /var/www/docker-aio; - -WORKDIR /var/www/docker-aio - -RUN set -ex; \ + usermod -u 33 -g 33 www-data; \ + \ apk add --no-cache \ util-linux-misc \ ca-certificates \ @@ -36,16 +38,14 @@ RUN set -ex; \ sudo \ netcat-openbsd \ curl \ - grep - -RUN set -ex; \ + grep; \ + \ apk add --no-cache --virtual .build-deps \ autoconf \ build-base; \ pecl install APCu-5.1.22; \ docker-php-ext-enable apcu; \ rm -r /tmp/pear; \ - \ runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ | tr ',' '\n' \ @@ -57,15 +57,8 @@ RUN set -ex; \ grep -q '^pm = dynamic' /usr/local/etc/php-fpm.d/www.conf; \ sed -i 's/^pm = dynamic/pm = ondemand/' /usr/local/etc/php-fpm.d/www.conf; \ sed -i 's/^pm.max_children =.*/pm.max_children = 80/' /usr/local/etc/php-fpm.d/www.conf; \ - sed -i 's|access.log = /proc/self/fd/2|access.log = /proc/self/fd/1|' /usr/local/etc/php-fpm.d/docker.conf - -COPY --from=caddy /usr/bin/caddy /usr/bin/ -RUN chmod +x /usr/bin/caddy - -COPY --from=docker /usr/local/bin/docker /usr/local/bin/ -RUN chmod +x /usr/local/bin/docker - -RUN set -e && \ + sed -i 's|access.log = /proc/self/fd/2|access.log = /proc/self/fd/1|' /usr/local/etc/php-fpm.d/docker.conf; \ + \ apk add --no-cache git; \ wget https://getcomposer.org/installer -O - | php -- --install-dir=/usr/local/bin --filename=composer; \ chmod +x /usr/local/bin/composer; \ @@ -75,22 +68,19 @@ RUN set -e && \ chown www-data:www-data -R /var/www/docker-aio; \ cd php; \ sudo -u www-data composer install --no-dev; \ - sudo -u www-data composer clearcache; \ + sudo -u www-data composer clear-cache; \ cd ..; \ rm -f /usr/local/bin/composer; \ - chmod 770 -R ./; \ - chown www-data:www-data -R /var/www; \ - rm -r ./php/data; \ - rm -r ./php/session; \ - apk del --no-cache git - -RUN mkdir -p /etc/apache2/certs && \ - cd /etc/apache2/certs && \ - openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=DE/ST=BE/L=Local/O=Dev/CN=nextcloud.local" -keyout ./ssl.key -out ./ssl.crt; - -COPY mastercontainer.conf /etc/apache2/sites-available/ - -RUN sed -i \ + chmod -R 770 /var/www/docker-aio; \ + chown -R www-data:www-data /var/www; \ + rm -r php/data; \ + rm -r php/session; \ + \ + mkdir -p /etc/apache2/certs; \ + cd /etc/apache2/certs; \ + openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=DE/ST=BE/L=Local/O=Dev/CN=nextcloud.local" -keyout /etc/apache2/certs/ssl.key -out /etc/apache2/certs/ssl.crt; \ + \ + sed -i \ -e '/^Listen /d' \ -e 's/User apache/User www-data/g' \ -e 's/Group apache/Group www-data/g' \ @@ -109,31 +99,23 @@ RUN sed -i \ echo "ServerName localhost" | tee -a /etc/apache2/httpd.conf; \ echo "LoadModule ssl_module modules/mod_ssl.so" | tee -a /etc/apache2/httpd.conf; \ echo "LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" | tee -a /etc/apache2/httpd.conf; \ - echo "Include /etc/apache2/sites-available/mastercontainer.conf" | tee -a /etc/apache2/httpd.conf - -RUN set -ex; \ + echo "Include /etc/apache2/sites-available/mastercontainer.conf" | tee -a /etc/apache2/httpd.conf; \ + \ rm -f /etc/apache2/conf.d/default.conf \ /etc/apache2/conf.d/userdir.conf \ - /etc/apache2/conf.d/info.conf - -RUN mkdir /var/log/supervisord; \ + /etc/apache2/conf.d/info.conf; \ + \ + mkdir /var/log/supervisord; \ mkdir /var/run/supervisord; -COPY Caddyfile / -COPY start.sh /usr/bin/ -COPY backup-time-file-watcher.sh / -COPY session-deduplicator.sh / -COPY cron.sh / -COPY daily-backup.sh / -COPY supervisord.conf / -COPY healthcheck.sh / -RUN chmod +x /usr/bin/start.sh; \ - chmod +x /cron.sh; \ - chmod +x /session-deduplicator.sh; \ - chmod +x /backup-time-file-watcher.sh; \ - chmod +x /daily-backup.sh; \ - chmod a+r /Caddyfile; \ - chmod +x /healthcheck.sh +COPY --chmod=664 Caddyfile /Caddyfile +COPY --chmod=775 start.sh /usr/bin/start.sh +COPY --chmod=775 backup-time-file-watcher.sh /backup-time-file-watcher.sh +COPY --chmod=775 session-deduplicator.sh /session-deduplicator.sh +COPY --chmod=775 cron.sh /cron.sh +COPY --chmod=775 daily-backup.sh /daily-backup.sh +COPY --chmod=664 supervisord.conf /supervisord.conf +COPY --chmod=775 healthcheck.sh /healthcheck.sh USER root From 3b4d741c8e7dda78f9b9dcf45f1efd4aadfd7657 Mon Sep 17 00:00:00 2001 From: Zoey Date: Fri, 12 May 2023 17:58:47 +0200 Subject: [PATCH 2/3] put scripts into / Signed-off-by: Zoey --- Containers/mastercontainer/Dockerfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index 5c4312b3..b01bea51 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -108,18 +108,13 @@ RUN set -ex; \ mkdir /var/log/supervisord; \ mkdir /var/run/supervisord; +COPY --chmod=775 *.sh / COPY --chmod=664 Caddyfile /Caddyfile -COPY --chmod=775 start.sh /usr/bin/start.sh -COPY --chmod=775 backup-time-file-watcher.sh /backup-time-file-watcher.sh -COPY --chmod=775 session-deduplicator.sh /session-deduplicator.sh -COPY --chmod=775 cron.sh /cron.sh -COPY --chmod=775 daily-backup.sh /daily-backup.sh COPY --chmod=664 supervisord.conf /supervisord.conf -COPY --chmod=775 healthcheck.sh /healthcheck.sh USER root -ENTRYPOINT ["start.sh"] +ENTRYPOINT ["/start.sh"] CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] HEALTHCHECK CMD /healthcheck.sh From f917f129328c5a7b1a7ef1feee2509b4fc6af704 Mon Sep 17 00:00:00 2001 From: Zoey Date: Fri, 12 May 2023 18:00:33 +0200 Subject: [PATCH 3/3] move mastercontainer.conf to the end Signed-off-by: Zoey --- Containers/mastercontainer/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Containers/mastercontainer/Dockerfile b/Containers/mastercontainer/Dockerfile index b01bea51..4ac4d390 100644 --- a/Containers/mastercontainer/Dockerfile +++ b/Containers/mastercontainer/Dockerfile @@ -11,8 +11,6 @@ EXPOSE 80 EXPOSE 8080 EXPOSE 8443 -COPY mastercontainer.conf /etc/apache2/sites-available/mastercontainer.conf - COPY --from=caddy /usr/bin/caddy /usr/bin/caddy COPY --from=docker /usr/local/bin/docker /usr/local/bin/docker @@ -111,6 +109,7 @@ RUN set -ex; \ COPY --chmod=775 *.sh / COPY --chmod=664 Caddyfile /Caddyfile COPY --chmod=664 supervisord.conf /supervisord.conf +COPY mastercontainer.conf /etc/apache2/sites-available/mastercontainer.conf USER root