From 49a09cd242ff144cd26e3f4528743fdbe8661198 Mon Sep 17 00:00:00 2001 From: furyhawk Date: Tue, 1 Jul 2025 12:29:34 +0800 Subject: [PATCH] feat: add Docker Compose configuration for Nextcloud with PostgreSQL, Redis, and Nginx --- swarm/nextcloud.yaml | 79 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 swarm/nextcloud.yaml diff --git a/swarm/nextcloud.yaml b/swarm/nextcloud.yaml new file mode 100644 index 0000000..cfed77c --- /dev/null +++ b/swarm/nextcloud.yaml @@ -0,0 +1,79 @@ +services: + # Note: PostgreSQL is an external service. You can find more information about the configuration here: + # https://hub.docker.com/_/postgres + db: + # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server + image: postgres:alpine + restart: always + volumes: + - db:/var/lib/postgresql/data:Z + env_file: + - db.env + + # Note: Redis is an external service. You can find more information about the configuration here: + # https://hub.docker.com/_/redis + redis: + image: redis:alpine + restart: always + + app: + image: nextcloud:fpm-alpine + restart: always + volumes: + - nextcloud:/var/www/html:z + # NOTE: The `volumes` config of the `cron` and `app` containers must match + environment: + - POSTGRES_HOST=db + - REDIS_HOST=redis + env_file: + - db.env + depends_on: + - db + - redis + + # Note: Nginx is an external service. You can find more information about the configuration here: + # https://hub.docker.com/_/nginx/ + web: + image: nginx:alpine-slim + environment: + - DOMAIN=${DOMAIN} + restart: always + expose: + - "80" + volumes: + # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html + - ./web/nginx.conf:/etc/nginx/nginx.conf:ro + # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing) + - nextcloud:/var/www/html:z,ro + depends_on: + - app + networks: + - traefik-public + deploy: + restart_policy: + condition: any + delay: 5s + max_attempts: 3 + labels: + - traefik.enable=true + - traefik.swarm.network=traefik-public + - traefik.constraint-label=traefik-public + - traefik.http.routers.nextcloud.entrypoints=https + - traefik.http.routers.nextcloud.rule=Host(`nextcloud.${DOMAIN}`) + - traefik.http.routers.nextcloud.tls.certresolver=le + - traefik.http.services.nextcloud.loadbalancer.server.port=80 + + cron: + image: nextcloud:fpm-alpine + restart: always + volumes: + - nextcloud:/var/www/html:z + # NOTE: The `volumes` config of the `cron` and `app` containers must match + entrypoint: /cron.sh + depends_on: + - db + - redis + +volumes: + db: + nextcloud: \ No newline at end of file