mirror of
https://github.com/nextcloud/all-in-one.git
synced 2024-09-21 15:26:16 +08:00
Merge pull request #2497 from nextcloud/nextcloud-dockerfile
optimize nextcloud Dockerfile
This commit is contained in:
commit
0b50fbd7f1
|
@ -1,6 +1,19 @@
|
||||||
# From https://github.com/nextcloud/docker/blob/master/23/fpm-alpine/Dockerfile
|
# From https://github.com/nextcloud/docker/blob/master/23/fpm-alpine/Dockerfile
|
||||||
FROM php:8.1.19-fpm-alpine3.17
|
FROM php:8.1.19-fpm-alpine3.17
|
||||||
|
|
||||||
|
ENV PHP_MEMORY_LIMIT 512M
|
||||||
|
ENV PHP_UPLOAD_LIMIT 10G
|
||||||
|
ENV PHP_MAX_TIME 3600
|
||||||
|
ENV NEXTCLOUD_VERSION 26.0.2
|
||||||
|
|
||||||
|
COPY --chmod=775 *.sh /
|
||||||
|
COPY --chmod=774 upgrade.exclude /upgrade.exclude
|
||||||
|
COPY config/*.php /
|
||||||
|
COPY supervisord.conf /supervisord.conf
|
||||||
|
|
||||||
|
VOLUME /mnt/ncdata
|
||||||
|
VOLUME /var/www/html
|
||||||
|
|
||||||
# Custom: change id of www-data user as it needs to be the same like on old installations
|
# Custom: change id of www-data user as it needs to be the same like on old installations
|
||||||
RUN set -ex; \
|
RUN set -ex; \
|
||||||
apk add --no-cache shadow; \
|
apk add --no-cache shadow; \
|
||||||
|
@ -8,22 +21,14 @@ RUN set -ex; \
|
||||||
groupmod -g 333 xfs; \
|
groupmod -g 333 xfs; \
|
||||||
usermod -u 333 -g 333 xfs; \
|
usermod -u 333 -g 333 xfs; \
|
||||||
addgroup -g 33 -S www-data; \
|
addgroup -g 33 -S www-data; \
|
||||||
adduser -u 33 -D -S -G www-data www-data
|
adduser -u 33 -D -S -G www-data www-data; \
|
||||||
|
|
||||||
# entrypoint.sh and cron.sh dependencies
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
\
|
||||||
|
# entrypoint.sh and cron.sh dependencies
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
rsync \
|
rsync \
|
||||||
;
|
; \
|
||||||
|
|
||||||
# install the PHP extensions we need
|
# install the PHP extensions we need
|
||||||
# see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html
|
# see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html
|
||||||
ENV PHP_MEMORY_LIMIT 512M
|
|
||||||
ENV PHP_UPLOAD_LIMIT 10G
|
|
||||||
ENV PHP_MAX_TIME 3600
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
apk add --no-cache --virtual .build-deps \
|
apk add --no-cache --virtual .build-deps \
|
||||||
$PHPIZE_DEPS \
|
$PHPIZE_DEPS \
|
||||||
autoconf \
|
autoconf \
|
||||||
|
@ -80,11 +85,11 @@ RUN set -ex; \
|
||||||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
||||||
)"; \
|
)"; \
|
||||||
apk add --virtual .nextcloud-phpext-rundeps $runDeps; \
|
apk add --virtual .nextcloud-phpext-rundeps $runDeps; \
|
||||||
apk del .build-deps
|
apk del .build-deps; \
|
||||||
|
\
|
||||||
# set recommended PHP.ini settings
|
# set recommended PHP.ini settings
|
||||||
# see https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/server_tuning.html#enable-php-opcache
|
# see https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/server_tuning.html#enable-php-opcache
|
||||||
RUN { \
|
{ \
|
||||||
echo 'opcache.interned_strings_buffer=32'; \
|
echo 'opcache.interned_strings_buffer=32'; \
|
||||||
echo 'opcache.save_comments=1'; \
|
echo 'opcache.save_comments=1'; \
|
||||||
echo 'opcache.revalidate_freq=60'; \
|
echo 'opcache.revalidate_freq=60'; \
|
||||||
|
@ -102,15 +107,10 @@ RUN { \
|
||||||
echo 'max_input_time=${PHP_MAX_TIME}'; \
|
echo 'max_input_time=${PHP_MAX_TIME}'; \
|
||||||
} > /usr/local/etc/php/conf.d/nextcloud.ini; \
|
} > /usr/local/etc/php/conf.d/nextcloud.ini; \
|
||||||
\
|
\
|
||||||
mkdir /var/www/data; \
|
mkdir -p /var/www/data; \
|
||||||
chown -R www-data:root /var/www; \
|
chown -R www-data:root /var/www; \
|
||||||
chmod -R g=u /var/www
|
chmod -R g=u /var/www; \
|
||||||
|
\
|
||||||
VOLUME /var/www/html
|
|
||||||
|
|
||||||
ENV NEXTCLOUD_VERSION 26.0.2
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
apk add --no-cache --virtual .fetch-deps \
|
apk add --no-cache --virtual .fetch-deps \
|
||||||
bzip2 \
|
bzip2 \
|
||||||
gnupg \
|
gnupg \
|
||||||
|
@ -130,27 +130,18 @@ RUN set -ex; \
|
||||||
mkdir -p /usr/src/nextcloud/data; \
|
mkdir -p /usr/src/nextcloud/data; \
|
||||||
mkdir -p /usr/src/nextcloud/custom_apps; \
|
mkdir -p /usr/src/nextcloud/custom_apps; \
|
||||||
chmod +x /usr/src/nextcloud/occ; \
|
chmod +x /usr/src/nextcloud/occ; \
|
||||||
apk del .fetch-deps
|
mkdir -p /usr/src/nextcloud/config; \
|
||||||
|
mv /*.php /usr/src/nextcloud/config/; \
|
||||||
COPY *.sh upgrade.exclude /
|
apk del .fetch-deps; \
|
||||||
COPY config/* /usr/src/nextcloud/config/
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
|
||||||
CMD ["php-fpm"]
|
|
||||||
|
|
||||||
# Template from https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/full/fpm-alpine/Dockerfile
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
\
|
||||||
|
# Template from https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/full/fpm-alpine/Dockerfile
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
ffmpeg \
|
ffmpeg \
|
||||||
procps \
|
procps \
|
||||||
samba-client \
|
samba-client \
|
||||||
supervisor \
|
supervisor \
|
||||||
# libreoffice \
|
# libreoffice \
|
||||||
;
|
; \
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
\
|
||||||
apk add --no-cache --virtual .build-deps \
|
apk add --no-cache --virtual .build-deps \
|
||||||
$PHPIZE_DEPS \
|
$PHPIZE_DEPS \
|
||||||
|
@ -178,21 +169,12 @@ RUN set -ex; \
|
||||||
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
|
||||||
)"; \
|
)"; \
|
||||||
apk add --virtual .nextcloud-phpext-rundeps $runDeps; \
|
apk add --virtual .nextcloud-phpext-rundeps $runDeps; \
|
||||||
apk del .build-deps
|
apk del .build-deps; \
|
||||||
|
\
|
||||||
RUN mkdir -p \
|
mkdir -p \
|
||||||
/var/log/supervisord \
|
/var/log/supervisord \
|
||||||
/var/run/supervisord \
|
/var/run/supervisord \
|
||||||
;
|
; \
|
||||||
|
|
||||||
COPY supervisord.conf /
|
|
||||||
|
|
||||||
ENV NEXTCLOUD_UPDATE=1
|
|
||||||
|
|
||||||
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]
|
|
||||||
|
|
||||||
# Custom:
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
\
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
bash \
|
bash \
|
||||||
|
@ -206,60 +188,38 @@ RUN set -ex; \
|
||||||
sudo \
|
sudo \
|
||||||
grep \
|
grep \
|
||||||
nodejs \
|
nodejs \
|
||||||
coreutils;
|
coreutils; \
|
||||||
|
\
|
||||||
RUN set -ex; \
|
|
||||||
grep -q '^pm = dynamic' /usr/local/etc/php-fpm.d/www.conf; \
|
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 = 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/^pm.max_children =.*/pm.max_children = 80/' /usr/local/etc/php-fpm.d/www.conf; \
|
||||||
sed -i 's/^pm.start_servers =.*/pm.start_servers = 2/' /usr/local/etc/php-fpm.d/www.conf; \
|
sed -i 's/^pm.start_servers =.*/pm.start_servers = 2/' /usr/local/etc/php-fpm.d/www.conf; \
|
||||||
sed -i 's/^pm.min_spare_servers =.*/pm.min_spare_servers = 1/' /usr/local/etc/php-fpm.d/www.conf; \
|
sed -i 's/^pm.min_spare_servers =.*/pm.min_spare_servers = 1/' /usr/local/etc/php-fpm.d/www.conf; \
|
||||||
sed -i 's/^pm.max_spare_servers =.*/pm.max_spare_servers = 3/' /usr/local/etc/php-fpm.d/www.conf; \
|
sed -i 's/^pm.max_spare_servers =.*/pm.max_spare_servers = 3/' /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
|
sed -i 's|access.log = /proc/self/fd/2|access.log = /proc/self/fd/1|' /usr/local/etc/php-fpm.d/docker.conf; \
|
||||||
|
\
|
||||||
RUN set -ex; \
|
|
||||||
rm -rf /tmp/nextcloud-aio && \
|
rm -rf /tmp/nextcloud-aio && \
|
||||||
mkdir -p /tmp/nextcloud-aio && \
|
mkdir -p /tmp/nextcloud-aio && \
|
||||||
cd /tmp/nextcloud-aio && \
|
cd /tmp/nextcloud-aio && \
|
||||||
git clone https://github.com/nextcloud-releases/all-in-one.git --depth 1 .; \
|
git clone https://github.com/nextcloud-releases/all-in-one.git --depth 1 .; \
|
||||||
mkdir -p /usr/src/nextcloud/apps/nextcloud-aio; \
|
mkdir -p /usr/src/nextcloud/apps/nextcloud-aio; \
|
||||||
cp -r ./app/* /usr/src/nextcloud/apps/nextcloud-aio/
|
cp -r ./app/* /usr/src/nextcloud/apps/nextcloud-aio/; \
|
||||||
|
\
|
||||||
RUN set -ex; \
|
|
||||||
chown www-data:root -R /usr/src && \
|
chown www-data:root -R /usr/src && \
|
||||||
chown www-data:root -R /usr/local/etc/php/conf.d && \
|
chown www-data:root -R /usr/local/etc/php/conf.d && \
|
||||||
chown www-data:root -R /usr/local/etc/php-fpm.d && \
|
chown www-data:root -R /usr/local/etc/php-fpm.d && \
|
||||||
rm -r /usr/src/nextcloud/apps/updatenotification
|
rm -r /usr/src/nextcloud/apps/updatenotification; \
|
||||||
|
\
|
||||||
COPY start.sh /
|
|
||||||
COPY notify.sh /
|
|
||||||
COPY notify-all.sh /
|
|
||||||
RUN set -ex; \
|
|
||||||
chmod +x /start.sh && \
|
|
||||||
chmod +x /entrypoint.sh && \
|
|
||||||
chmod +r /upgrade.exclude && \
|
|
||||||
chmod +x /cron.sh && \
|
|
||||||
chmod +x /notify.sh && \
|
|
||||||
chmod +x /notify-all.sh && \
|
|
||||||
chmod +x /run-exec-commands.sh && \
|
|
||||||
chmod +x /healthcheck.sh
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
mkdir /mnt/ncdata; \
|
|
||||||
chown www-data:www-data /mnt/ncdata;
|
|
||||||
|
|
||||||
VOLUME /mnt/ncdata
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
mkdir -p /nc-updater; \
|
mkdir -p /nc-updater; \
|
||||||
chown -R www-data:www-data /nc-updater; \
|
chown -R www-data:www-data /nc-updater; \
|
||||||
chmod -R 770 /nc-updater
|
chmod -R 770 /nc-updater; \
|
||||||
|
\
|
||||||
# Give root a random password
|
# Give root a random password
|
||||||
RUN echo "root:$(openssl rand -base64 12)" | chpasswd
|
echo "root:$(openssl rand -base64 12)" | chpasswd
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
ENTRYPOINT ["/start.sh"]
|
ENTRYPOINT ["/start.sh"]
|
||||||
|
CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]
|
||||||
|
|
||||||
HEALTHCHECK CMD sudo -E -u www-data bash /healthcheck.sh
|
HEALTHCHECK CMD sudo -E -u www-data bash /healthcheck.sh
|
||||||
LABEL com.centurylinklabs.watchtower.monitor-only="true"
|
LABEL com.centurylinklabs.watchtower.monitor-only="true"
|
||||||
|
|
Loading…
Reference in a new issue