docker-compose for nextcloud fpm with mariadb and nginx proxy as well as self signed ssl
Folders for mounting data must be created, read below how to do that. Next, copy all .env.example files to only .env extension and then edit each one with your settings.
MariaDB and PHP-FPM are configured to run on server with 1 CPU (4 threads) and 16 GB of RAM. If your configuration differs, edit database configuration my.cnf and php configuration Dockerfile files. There is no general rule for performance tweaking so look for explanations elsewhere. In /var/pool is a huge BTRFS raid disk pool mounted on my server.
Values that are ought to be changed before running:
- Update database passwords in db.env (default: password123)
- Update domains in nginx.env (default: 127.0.0.1)
- Update ssl certificates to match your domain name in sslcert.env (default: 127.0.0.1)
- Update volume paths for each service in docker-compose.yml (default: /var/pool/nextcloud)
- Update max upload size in proxy/uploadsize.conf and web/nginx.conf (default: 25 GB)
Make sure docker volume paths exist in the host sytem. If the default configuration is used, a directory tree can be created with the following commands:
mkdir -p /var/pool/nextcloud/{db,data,certs,vhost,html,mail}
mkdir -p /var/ramdisk/{dbcache,rediscache}
Mount free ram as ramdisk for caching:
sudo mount -t tmpfs -o size=2048M tmpfs /var/ramdisk/dbcache
sudo mount -t tmpfs -o size=2048M tmpfs /var/ramdisk/rediscache
Save ramdisks to fstab file:
none /var/ramdisk/dbcache tmpfs nodev,nosuid,noexec,nodiratime,size=2048M 0 0
none /var/ramdisk/rediscache tmpfs nodev,nosuid,noexec,nodiratime,size=2048M 0 0
Running containers:
docker-compose build --pull
docker-compose up -d
Custom script is automatically copied to app container image. It can be run by executing:
docker-compose exec --user www-data app docker-entrypoint-custom
docker-compose down
And repeat steps for running.
Problems I ran into:
Verify redis is being used:
docker-compose exec --user root redis redis-cli MONITOR
Sometimes trusted domains are not picked up in app image. Peek in this file to verify:
docker-compose exec --user www-data app cat config/config.php