diff --git a/Dockerfile b/Dockerfile index 173bcec..5f15fdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,12 @@ # ADD CRON and SMBCLIENT # see https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles -FROM local-nextcloud:26-apache-zts +FROM local-nextcloud:27-apache-zts + +# For getting the newest redis-server +RUN apt-get update && apt-get install -y lsb-release gpg && \ + echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" > /etc/apt/sources.list.d/redis.list && \ + curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; RUN apt-get update && apt-get install -y \ supervisor procps smbclient redis-server imagemagick \ @@ -46,21 +52,22 @@ stderr_logfile_maxbytes=0\n\ command=/cron.sh" > /supervisord.conf # disable unused Apache2 module & enable used modules -RUN a2dismod access_compat reqtimeout status mpm_prefork -RUN a2dismod -f deflate -RUN a2enmod mpm_event proxy_fcgi proxy http2 rewrite headers setenvif env mime dir alias remoteip filter brotli - -# enable FastCGI -RUN sed -i -e "s!SetHandler .*!SetHandler 'proxy:unix:/var/run/php-fpm/php-fpm.sock|fcgi://localhost'!g" /etc/apache2/conf-enabled/docker-php.conf -RUN echo "SetEnv proxy-sendcl 1" >> /etc/apache2/conf-enabled/docker-php.conf -RUN echo "AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/json image/svg+xml" >> /etc/apache2/conf-enabled/docker-php.conf +RUN a2dismod access_compat reqtimeout status mpm_prefork ;\ + a2dismod -f deflate ;\ + a2enmod mpm_event proxy_fcgi proxy http2 rewrite headers setenvif env mime dir alias remoteip filter brotli -RUN cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf -RUN sed -i -e "s/include=NONE\//include=/g" /usr/local/etc/php-fpm.conf +# Tune HTTP/2 +RUN sed -i -e "s!! H2WindowSize 1048576\n H2StreamMaxMemSize 5120000000\n!g" /etc/apache2/mods-enabled/http2.conf -RUN mkdir -p /var/run/php-fpm -RUN cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf -RUN sed -i -e "s!^\(listen =\).*!\1 /var/run/php-fpm/php-fpm.sock!g" \ +# enable FastCGI +RUN sed -i -e "s!SetHandler .*!SetHandler 'proxy:unix:/var/run/php-fpm/php-fpm.sock|fcgi://localhost'!g" /etc/apache2/conf-enabled/docker-php.conf ;\ + echo "SetEnv proxy-sendcl 1" >> /etc/apache2/conf-enabled/docker-php.conf ;\ + echo "AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml text/css text/javascript application/javascript application/json image/svg+xml" >> /etc/apache2/conf-enabled/docker-php.conf ;\ + cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf ;\ + sed -i -e "s/include=NONE\//include=/g" /usr/local/etc/php-fpm.conf ;\ + mkdir -p /var/run/php-fpm ;\ + cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf ;\ + sed -i -e "s!^\(listen =\).*!\1 /var/run/php-fpm/php-fpm.sock!g" \ -e "s/^;\(listen.\(owner\|group\) = www-data\)/\1/g" \ -e "s/^\(pm =\).*/\1 ondemand/g" \ -e "s/^\(pm.max_children =\).*/\1 \${PHP_FPM_MAX_CHILDREN}/g" \ @@ -76,25 +83,30 @@ ENV PHP_FPM_PROCESS_IDLE_TIMEOUT=10s ENV PHP_FPM_MAX_REQUESTS=400 # Tune APCu -RUN echo "apc.shm_size = ${PHP_APC_SHM_SIZE}" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini - ENV PHP_APC_SHM_SIZE=128M +RUN echo "apc.shm_size=\${PHP_APC_SHM_SIZE}" >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini # Make local cache dir # You can use it in config.php > config_path RUN mkdir -p /var/www/nxc_cache && chown www-data /var/www/nxc_cache -# Install redis using with unixsocket -RUN mkdir -p /var/run/redis && chown redis:redis /var/run/redis -RUN sed -i -e "s/^\(port\) .*/\1 0/g" \ +# Setup redis using with unixsocket +RUN mkdir -p /var/run/redis && chown redis:redis /var/run/redis ;\ + sed -i -e "s/^\(port\) .*/\1 0/g" \ -e "s/^\(daemonize\) .*/\1 no/g" \ -e "s!^\(logfile\) .*!\1 ''!g" \ -e "s/^\(always-show-logo\) .*/\1 no/g" \ - -e "s/^# \(unixsocket \)/\1/g" \ + -e "s!^# \(unixsocket \).*!\1/var/run/redis/redis-server.sock!g" \ -e "s/^# \(unixsocketperm\) .*/\1 770/g" \ -e "s/^\(save .*\)/# \1/g" \ - /etc/redis/redis.conf -RUN usermod -a -G redis www-data + /etc/redis/redis.conf ;\ + usermod -a -G redis www-data ;\ + ( echo 'session.save_handler=redis' ;\ + echo 'session.save_path="unix:///var/run/redis/redis-server.sock"' ;\ + echo 'redis.session.locking_enabled=1' ;\ + echo 'redis.session.lock_retries=1' ;\ + echo 'redis.session.lock_wait_time=10000' ;\ + ) >> /usr/local/etc/php/conf.d/docker-php-ext-redis.ini # Enable PDF preview # You can use it with modifying config.php diff --git a/README.md b/README.md index 684e541..e3ef7fa 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,12 @@ The last part is customized nextcloud. It is based on the 2nd image. The additio ``` 'cache_path' => '/var/www/nxc_cache', ``` -- Install Redis Server +- Setup Redis Server - You can use it to write the following settings in the config/config.php ``` - 'memcache.distributed' => '\OC\Memcache\Redis', + 'filelocking.enabled' => true, + 'memcache.locking' => '\\OC\Memcache\Redis', + 'memcache.distributed' => '\\OC\Memcache\Redis', 'redis' => [ 'host' => '/var/run/redis/redis-server.sock', 'port' => 0, diff --git a/build.sh b/build.sh index 97364f2..060c861 100755 --- a/build.sh +++ b/build.sh @@ -1,33 +1,50 @@ #!/bin/sh ### 1st stage: php ### -PHP_VER=8.1 +PHP_VER=8.2 PHP_TAG=local-php:$PHP_VER-apache-zts-bullseye PHP_DIR=./php/$PHP_VER/bullseye/apache/ -# Update the repository -(cd php; git reset --hard; git pull) -# Modify Dockerfile -sed -i -e "s/\(--with-apxs2\)/\1 --enable-zts --disable-zend-signals --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data /g" $PHP_DIR/Dockerfile -# Build -docker build -t $PHP_TAG --pull --no-cache $PHP_DIR +function build_php () { + # Update the repository + (cd php; git reset --hard; git pull https://github.com/docker-library/php/ master) + # Modify Dockerfile + sed -i -e "s/\(--with-apxs2\)/\1 --enable-zts --disable-zend-signals --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data /g" \ + -e "s/\(gnupg\)/\1 aria2/g" \ + -e "s/curl -fsSL/aria2c -x8/g" \ + $PHP_DIR/Dockerfile + # Build + docker build -t $PHP_TAG --pull --no-cache $PHP_DIR +} ### 2nd stage: nextcloud ### NEXTCLOUD_VER=`awk -F'.' '{print $1}' nextcloud/latest.txt` NEXTCLOUD_TAG=local-nextcloud:$NEXTCLOUD_VER-apache-zts NEXTCLOUD_DIR=./nextcloud/$NEXTCLOUD_VER/apache/ -# Update the repository -(cd nextcloud; git reset --hard; git pull) -# Modify Dockerfile -sed -i -e "s!FROM .*!FROM $PHP_TAG!g" $NEXTCLOUD_DIR/Dockerfile -# Build -docker build -t $NEXTCLOUD_TAG $NEXTCLOUD_DIR +function build_nextcloud () { + # Update the repository + (cd nextcloud; git reset --hard; git pull https://github.com/nextcloud/docker/ master) + # Modify Dockerfile for faster download + sed -i -e "s!FROM .*!FROM $PHP_TAG!g" \ + -e "s/\(gnupg\)/\1 aria2/g" \ + -e "s/curl -fsSL/aria2c -x8/g" \ + $NEXTCLOUD_DIR/Dockerfile + # Build + docker build -t $NEXTCLOUD_TAG $NEXTCLOUD_DIR +} ### 3rd stage: nextcloud-custom ### CUSTOM_TAG=nextcloud-custom +function build_custom () { -# Modify Dockerfile -sed -i -e "s!FROM .*!FROM $NEXTCLOUD_TAG!g" ./Dockerfile -# Build -docker build -t $CUSTOM_TAG . + # Modify Dockerfile + sed -i -e "s!FROM .*!FROM $NEXTCLOUD_TAG!g" ./Dockerfile + # Build + docker build -t $CUSTOM_TAG . +} + +### MAIN ### +build_php +build_nextcloud +build_custom diff --git a/nextcloud b/nextcloud index 2d8f990..c496644 160000 --- a/nextcloud +++ b/nextcloud @@ -1 +1 @@ -Subproject commit 2d8f990304e76071602375a197b65692fa2de69a +Subproject commit c4966442a623e04bdc438a2023b8bdb640c4408a diff --git a/php b/php index 59da5b0..4717c12 160000 --- a/php +++ b/php @@ -1 +1 @@ -Subproject commit 59da5b0a2dda2bc22d053263ea5fc860ddca65a2 +Subproject commit 4717c12a15eb1c42be2e03edc8ca3ebc23e217ec