[HOW-TO] Get a rock solid Nextcloud installation

Hello,

I’ve been using TrueNAS Core + NextCloud jail for a few years and with its up and downs, it’s been working more or less okay. However, I’m in the process of moving everything I can to docker so it’s host agnostic and I can change it as I please.

With that being said, I embarked on a quest to get Nextcloud to do one thing, its job! I’ve been tinkering for a few days testing different configurations, DB and installation methods and while this might have errors and won’t be perfect it’s the most rock solid I could get it so far, including syncing from web and clients (Windows and macOS)

What we’re going to use

  • Proxmox as the main host OS
  • A container inside Proxmox (they call it LXC)
  • We will use docker + portainer
  • We will use docker image nextcloud:production-apache (avoid latest, there are quite a few bugs on V25)
  • We will use docker image postgres:14. Forget about MariaDB, I’m not even sure why it’s recommended. If I use it I just get tons of deadlocks, etc. 0 problems with Postgres so far
  • We will use nginx proxy manager to add HTTPS for public exposure

Attaching below my docker-compose files

version: '3'

services:
  db:
    image: postgres:14
    restart: always
    volumes:
      - /root/docker/nextcloud/db:/var/lib/postgresql/data
    env_file:
      - stack.env

  redis:
    image: redis:alpine
    restart: always

  app:
    image: nextcloud:production-apache
    restart: always
    ports:
      - 8082:80

    volumes:
      - /root/docker/nextcloud/nextcloud:/var/www/html
      - /mnt/ncdata/nextcloud_data:/var/www/html/data
    environment:
      - POSTGRES_HOST=db
      - REDIS_HOST=redis
    env_file:
      - stack.env
    depends_on:
      - db
      - redis

  cron:
    image: nextcloud:apache
    restart: always
    volumes:
      - /root/docker/nextcloud/nextcloud:/var/www/html
      - /mnt/ncdata/nextcloud_data:/var/www/html/data
    entrypoint: /cron.sh
    depends_on:
      - db
      - redis

stack.env file

POSTGRES_PASSWORD=nextcloud
POSTGRES_DB=nextcloud
POSTGRES_USER=nextcloud

As you can see I’m also using a specific folder for the data directory so I can access my TrueNAS ZFS storage but the rest of nextcloud runs on my Proxmox NVME SSD

From here you might want to install Nginx-proxy manager or any other reverse proxy of your liking. Here’s my docker-compose for it

version: '3'
services:
  npm:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    volumes:
      - /root/docker/npm/data:/data
      - /root/docker/npm/letsencrypt:/etc/letsencrypt

You will also want to take a look at Nextcloud’s docker repo

1 Like