nextcloud: use redis for file locking cache

This commit is contained in:
Wonderfall 2016-10-16 14:04:01 +02:00
parent e0e21acf73
commit 038d0bffcd
10 changed files with 58 additions and 7 deletions

View File

@ -9,6 +9,7 @@ ENV UID=991 GID=991 \
UPLOAD_MAX_SIZE=10G \ UPLOAD_MAX_SIZE=10G \
APC_SHM_SIZE=128M \ APC_SHM_SIZE=128M \
OPCACHE_MEM_SIZE=128 \ OPCACHE_MEM_SIZE=128 \
REDIS_MAX_MEMORY=64mb \
CRON_PERIOD=15m \ CRON_PERIOD=15m \
TZ=Etc/UTC \ TZ=Etc/UTC \
DB_TYPE=sqlite3 \ DB_TYPE=sqlite3 \
@ -34,6 +35,7 @@ RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/a
samba-client \ samba-client \
su-exec \ su-exec \
tzdata \ tzdata \
redis \
php7@commuedge \ php7@commuedge \
php7-fpm@commuedge \ php7-fpm@commuedge \
php7-intl@commuedge \ php7-intl@commuedge \
@ -98,6 +100,7 @@ COPY nginx.conf /etc/nginx/nginx.conf
COPY php-fpm.conf /etc/php7/php-fpm.conf COPY php-fpm.conf /etc/php7/php-fpm.conf
COPY opcache.ini /etc/php7/conf.d/00_opcache.ini COPY opcache.ini /etc/php7/conf.d/00_opcache.ini
COPY apcu.ini /etc/php7/conf.d/apcu.ini COPY apcu.ini /etc/php7/conf.d/apcu.ini
COPY redis.conf /etc/redis.conf
COPY run.sh /usr/local/bin/run.sh COPY run.sh /usr/local/bin/run.sh
COPY setup.sh /usr/local/bin/setup.sh COPY setup.sh /usr/local/bin/setup.sh
COPY occ /usr/local/bin/occ COPY occ /usr/local/bin/occ
@ -105,7 +108,7 @@ COPY s6.d /etc/s6.d
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/*
VOLUME /data /config /apps2 VOLUME /data /config /apps2 /var/lib/redis
EXPOSE 8888 EXPOSE 8888

14
nextcloud/10.0/redis.conf Normal file
View File

@ -0,0 +1,14 @@
bind 127.0.0.1
protected-mode yes
port 0
unixsocket /tmp/redis.sock
unixsocketperm 700
daemonize no
pidfile /tmp/redis.pid
logfile /tmp/redis.log
save 900 1
save 300 10
save 60 10000
dbfilename dump.rdb
dir /var/lib/redis/
maxmemory <REDIS_MAX_MEMORY>

View File

@ -3,13 +3,14 @@
sed -i -e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/php7/php-fpm.conf \ sed -i -e "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /etc/nginx/nginx.conf /etc/php7/php-fpm.conf \
-e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /etc/php7/conf.d/apcu.ini \ -e "s/<APC_SHM_SIZE>/$APC_SHM_SIZE/g" /etc/php7/conf.d/apcu.ini \
-e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /etc/php7/conf.d/00_opcache.ini \ -e "s/<OPCACHE_MEM_SIZE>/$OPCACHE_MEM_SIZE/g" /etc/php7/conf.d/00_opcache.ini \
-e "s/<REDIS_MAX_MEMORY>/$REDIS_MAX_MEMORY/g" /etc/redis.conf \
-e "s/<CRON_PERIOD>/$CRON_PERIOD/g" /etc/s6.d/cron/run -e "s/<CRON_PERIOD>/$CRON_PERIOD/g" /etc/s6.d/cron/run
# Put the configuration and apps into volumes # Put the configuration and apps into volumes
ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null ln -sf /config/config.php /nextcloud/config/config.php &>/dev/null
ln -sf /apps2 /nextcloud &>/dev/null ln -sf /apps2 /nextcloud &>/dev/null
chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /tmp /etc/s6.d chown -R $UID:$GID /nextcloud /data /config /apps2 /etc/nginx /etc/php7 /var/log /var/lib/nginx /var/lib/redis /tmp /etc/s6.d
if [ ! -f /config/config.php ]; then if [ ! -f /config/config.php ]; then
# New installation, run the setup # New installation, run the setup

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec redis-server /etc/redis.conf

View File

@ -29,6 +29,13 @@ cat > $CONFIGFILE <<EOF;
'memcache.local' => '\OC\Memcache\APCu', 'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => '/tmp/redis.sock',
'port' => 0,
'timeout' => 0.0,
),
'instanceid' => '$instanceid', 'instanceid' => '$instanceid',
); );
?> ?>

View File

@ -10,7 +10,7 @@
- Automatic installation using environment variables. - Automatic installation using environment variables.
- Package integrity and authenticity checked during building process. - Package integrity and authenticity checked during building process.
- Data and apps persistence. - Data and apps persistence.
- OPCache & APCu already configured. - OPCache, APCu, Redis (file locking) installed and configured.
- system cron task running. - system cron task running.
- MySQL, PostgreSQL (server not built-in) and sqlite3 support. - MySQL, PostgreSQL (server not built-in) and sqlite3 support.
- Redis, FTP, SMB, LDAP support. - Redis, FTP, SMB, LDAP support.
@ -60,6 +60,7 @@ Don't forget to use a **strong password** for the admin account!
- **/data** : Nextcloud data. - **/data** : Nextcloud data.
- **/config** : config.php location. - **/config** : config.php location.
- **/apps2** : Nextcloud downloaded apps. - **/apps2** : Nextcloud downloaded apps.
- **/var/lib/redis** : Redis dumpfile location.
### Database ### Database
Basically, you can use a database instance running on the host or any other machine. An easier solution is to use an external database container. I suggest you to use MariaDB, which is a reliable database server. You can use the official `mariadb` image available on Docker Hub to create a database container, which must be linked to the Nextcloud container. PostgreSQL can also be used as well. Basically, you can use a database instance running on the host or any other machine. An easier solution is to use an external database container. I suggest you to use MariaDB, which is a reliable database server. You can use the official `mariadb` image available on Docker Hub to create a database container, which must be linked to the Nextcloud container. PostgreSQL can also be used as well.

View File

@ -7,6 +7,7 @@ ENV UID=991 GID=991 \
UPLOAD_MAX_SIZE=10G \ UPLOAD_MAX_SIZE=10G \
APC_SHM_SIZE=128M \ APC_SHM_SIZE=128M \
OPCACHE_MEM_SIZE=128 \ OPCACHE_MEM_SIZE=128 \
REDIS_MAX_MEMORY=64mb \
CRON_PERIOD=15m \ CRON_PERIOD=15m \
TZ=Etc/UTC \ TZ=Etc/UTC \
DB_TYPE=sqlite3 \ DB_TYPE=sqlite3 \
@ -31,6 +32,7 @@ RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/a
samba-client \ samba-client \
su-exec \ su-exec \
tzdata \ tzdata \
redis \
php7@commuedge \ php7@commuedge \
php7-fpm@commuedge \ php7-fpm@commuedge \
php7-intl@commuedge \ php7-intl@commuedge \
@ -82,6 +84,7 @@ COPY nginx.conf /etc/nginx/nginx.conf
COPY php-fpm.conf /etc/php7/php-fpm.conf COPY php-fpm.conf /etc/php7/php-fpm.conf
COPY opcache.ini /etc/php7/conf.d/00_opcache.ini COPY opcache.ini /etc/php7/conf.d/00_opcache.ini
COPY apcu.ini /etc/php7/conf.d/apcu.ini COPY apcu.ini /etc/php7/conf.d/apcu.ini
COPY redis.conf /etc/redis.conf
COPY run.sh /usr/local/bin/run.sh COPY run.sh /usr/local/bin/run.sh
COPY setup.sh /usr/local/bin/setup.sh COPY setup.sh /usr/local/bin/setup.sh
COPY occ /usr/local/bin/occ COPY occ /usr/local/bin/occ
@ -89,7 +92,7 @@ COPY s6.d /etc/s6.d
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/*
VOLUME /data /config /apps2 VOLUME /data /config /apps2 /var/lib/redis
EXPOSE 8888 EXPOSE 8888

View File

@ -0,0 +1,14 @@
bind 127.0.0.1
protected-mode yes
port 0
unixsocket /tmp/redis.sock
unixsocketperm 700
daemonize no
pidfile /tmp/redis.pid
logfile /tmp/redis.log
save 900 1
save 300 10
save 60 10000
dbfilename dump.rdb
dir /var/lib/redis/
maxmemory <REDIS_MAX_MEMORY>

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec redis-server /etc/redis.conf

View File

@ -29,6 +29,13 @@ cat > $CONFIGFILE <<EOF;
'memcache.local' => '\OC\Memcache\APCu', 'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => '/tmp/redis.sock',
'port' => 0,
'timeout' => 0.0,
),
'instanceid' => '$instanceid', 'instanceid' => '$instanceid',
); );
?> ?>
@ -85,10 +92,7 @@ php7 <<EOF > $CONFIG_TEMP && mv $CONFIG_TEMP $CONFIGFILE
<?php <?php
include("/config/config.php"); include("/config/config.php");
\$CONFIG['trusted_domains'] = array('$VIRTUAL_HOST');
//\$CONFIG['memcache.local'] = '\\OC\\Memcache\\Memcached'; //\$CONFIG['memcache.local'] = '\\OC\\Memcache\\Memcached';
//\$CONFIG['overwrite.cli.url'] = '/cloud';
\$CONFIG['mail_from_address'] = 'administrator'; # just the local part, matches our master administrator address \$CONFIG['mail_from_address'] = 'administrator'; # just the local part, matches our master administrator address
\$CONFIG['logtimezone'] = '$TZ'; \$CONFIG['logtimezone'] = '$TZ';