digitalboard.core/roles/nextcloud/templates/docker-compose.yml.j2
Simon Bärlocher 2104e5fe7d
feat: drop blanket recreates, ACME-DNS knobs, notify_push override
- Drop `recreate: always` from collabora/drawio/homarr/opencloud/traefik
  handlers and the authentik_outpost_ldap start task. `up -d` with
  `state: present` already recreates exactly the services whose
  compose definition changed; the blanket recreate was forcing
  restarts even when nothing relevant moved.
- Rewrite the `*_domains` Traefik Host loop to the `Host(\`a\`) ||
  Host(\`b\`)` form across authentik/collabora/garage/nextcloud so the
  rule still matches when traefik can't normalize the comma-form into
  the same canonical shape.
- Traefik: add `traefik_acme_tcp_only` (sets LEGO_EXPERIMENTAL_DNS_TCP_ONLY)
  and `traefik_acme_disable_ans_checks` (disables lego's authoritative-NS
  propagation check) for environments where the DNS path between the
  traefik container and the zone's nameservers is constrained.
- Traefik DMZ collector: two-step merge so a `traefik_dmz_exposed_services`
  entry that sets its own `backend_host` wins over the host fallback;
  lets a route target an internal FQDN covered by the backend cert's
  SANs instead of the raw IP.
- Nextcloud: add `nextcloud_notify_push_domain` override for the
  `occ notify_push:setup` call so the setup check can hit an internal
  FQDN instead of hairpinning through the DMZ. Push router now matches
  every entry in `nextcloud_domains`.
- Nextcloud: also %2F-escape slashes in the postgres user/password
  inside the notify_push DATABASE_URL.
2026-05-27 23:12:23 +02:00

170 lines
No EOL
6.4 KiB
Django/Jinja

services:
db:
image: {{ nextcloud_postgres_image }}
restart: always
environment:
POSTGRES_DB: {{ nextcloud_postgres_db }}
POSTGRES_USER: {{ nextcloud_postgres_user }}
POSTGRES_PASSWORD: {{ nextcloud_postgres_password }}
volumes:
- {{ nextcloud_docker_volume_dir }}/postgresql/:/var/lib/postgresql/
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro
networks:
- {{ nextcloud_backend_network }}
redis:
image: {{ nextcloud_redis_image }}
restart: always
command: ["redis-server", "--appendonly", "yes"]
volumes:
- {{ nextcloud_docker_volume_dir }}/redis/data:/data
networks:
- {{ nextcloud_backend_network }}
nginx:
image: nginx:alpine
restart: always
depends_on:
- nextcloud
volumes:
- {{ nextcloud_docker_volume_dir }}/nextcloud/:/var/www/html:ro
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- {{ nextcloud_backend_network }}
- {{ nextcloud_traefik_network }}
labels:
- traefik.enable=true
- traefik.docker.network={{ nextcloud_traefik_network }}
- traefik.http.routers.{{ nextcloud_service_name }}.rule={% for d in nextcloud_domains %}Host(`{{ d }}`){% if not loop.last %} || {% endif %}{% endfor +%}
{% if nextcloud_use_ssl %}
- traefik.http.routers.{{ nextcloud_service_name }}.entrypoints=websecure
- traefik.http.routers.{{ nextcloud_service_name }}.tls=true
{% if traefik_cert_mode | default('selfsigned') == 'acme' %}
- traefik.http.routers.{{ nextcloud_service_name }}.tls.certresolver={{ traefik_ssl_cert_resolver | default('dns') }}
{% endif %}
{% else %}
- traefik.http.routers.{{ nextcloud_service_name }}.entrypoints=web
{% endif %}
nextcloud-cron:
image: {{ nextcloud_image }}
restart: always
depends_on:
- nextcloud
entrypoint: /cron.sh
environment:
POSTGRES_HOST: db
POSTGRES_DB: {{ nextcloud_postgres_db }}
POSTGRES_USER: {{ nextcloud_postgres_user }}
POSTGRES_PASSWORD: {{ nextcloud_postgres_password }}
NEXTCLOUD_ADMIN_USER: {{ nextcloud_admin_user }}
NEXTCLOUD_ADMIN_PASSWORD: {{ nextcloud_admin_password }}
REDIS_HOST: redis
PHP_MEMORY_LIMIT: {{ nextcloud_memory_limit_mb }}M
PHP_UPLOAD_LIMIT: {{ nextcloud_upload_limit_mb }}M
OVERWRITEPROTOCOL: https
OVERWRITEHOST: {{ nextcloud_domains[0] }}
TRUSTED_PROXIES: "{{ nextcloud_trusted_proxies }}"
volumes:
- {{ nextcloud_docker_volume_dir }}/nextcloud/:/var/www/html
networks:
- {{ nextcloud_backend_network }}
{% for net in nextcloud_extra_networks %}
- {{ net }}
{% endfor %}
{% if nextcloud_extra_hosts is defined and nextcloud_extra_hosts | length > 0 %}
extra_hosts:
{% for host in nextcloud_extra_hosts %}
- "{{ host }}"
{% endfor %}
{% endif %}
nextcloud:
image: {{ nextcloud_image }}
scale: {{ nextcloud_scale_factor }}
restart: always
depends_on:
- db
- redis
environment:
POSTGRES_HOST: db
POSTGRES_DB: {{ nextcloud_postgres_db }}
POSTGRES_USER: {{ nextcloud_postgres_user }}
POSTGRES_PASSWORD: {{ nextcloud_postgres_password }}
NEXTCLOUD_ADMIN_USER: {{ nextcloud_admin_user }}
NEXTCLOUD_ADMIN_PASSWORD: {{ nextcloud_admin_password }}
REDIS_HOST: redis
PHP_MEMORY_LIMIT: {{ nextcloud_memory_limit_mb }}M
PHP_UPLOAD_LIMIT: {{ nextcloud_upload_limit_mb }}M
OVERWRITEPROTOCOL: https
OVERWRITEHOST: {{ nextcloud_domains[0] }}
TRUSTED_PROXIES: "{{ nextcloud_trusted_proxies }}"
{% if nextcloud_use_s3_storage %}
OBJECTSTORE_S3_KEY: {{ nextcloud_s3_key }}
OBJECTSTORE_S3_SECRET: {{ nextcloud_s3_secret }}
OBJECTSTORE_S3_REGION: {{ nextcloud_s3_region }}
OBJECTSTORE_S3_BUCKET: {{ nextcloud_s3_bucket }}
OBJECTSTORE_S3_HOST: {{ nextcloud_s3_host }}
OBJECTSTORE_S3_PORT: {{ nextcloud_s3_port }}
OBJECTSTORE_S3_SSL: {{ nextcloud_s3_ssl }}
OBJECTSTORE_S3_USEPATH_STYLE: {{ nextcloud_s3_usepath_style }}
OBJECTSTORE_S3_AUTOCREATE: {{ nextcloud_s3_autocreate }}
{% endif %}
volumes:
- {{ nextcloud_docker_volume_dir }}/nextcloud/:/var/www/html
networks:
- {{ nextcloud_backend_network }}
{% for net in nextcloud_extra_networks %}
- {{ net }}
{% endfor %}
{% if nextcloud_extra_hosts is defined and nextcloud_extra_hosts | length > 0 %}
extra_hosts:
{% for host in nextcloud_extra_hosts %}
- "{{ host }}"
{% endfor %}
{% endif %}
{% if nextcloud_enable_notify_push %}
notify-push:
image: {{ nextcloud_notify_push_image }}
restart: always
depends_on:
- redis
- db
volumes:
- {{ nextcloud_docker_volume_dir }}/nextcloud/:/var/www/html
environment:
PORT: "7867"
REDIS_URL: "redis://redis:6379"
DATABASE_URL: "postgres://{{ nextcloud_postgres_user | urlencode | replace('/', '%2F') }}:{{ nextcloud_postgres_password | urlencode | replace('/', '%2F') }}@db:5432/{{ nextcloud_postgres_db }}"
DATABASE_PREFIX: "oc_"
NEXTCLOUD_URL: "http://nginx"
networks:
- {{ nextcloud_backend_network }}
- {{ nextcloud_traefik_network }}
labels:
- traefik.enable=true
- traefik.docker.network={{ nextcloud_traefik_network }}
- traefik.http.routers.{{ nextcloud_service_name }}-push.rule=({% for d in nextcloud_domains %}Host(`{{ d }}`){% if not loop.last %} || {% endif %}{% endfor %}) && PathPrefix(`/push`)
- traefik.http.services.{{ nextcloud_service_name }}-push.loadbalancer.server.port=7867
{% if nextcloud_use_ssl %}
- traefik.http.routers.{{ nextcloud_service_name }}-push.entrypoints=websecure
- traefik.http.routers.{{ nextcloud_service_name }}-push.tls=true
{% if traefik_cert_mode | default('selfsigned') == 'acme' %}
- traefik.http.routers.{{ nextcloud_service_name }}-push.tls.certresolver={{ traefik_ssl_cert_resolver | default('dns') }}
{% endif %}
{% else %}
- traefik.http.routers.{{ nextcloud_service_name }}-push.entrypoints=web
{% endif %}
- traefik.http.middlewares.{{ nextcloud_service_name }}-push-https.headers.customrequestheaders.X-Forwarded-Proto=https
- traefik.http.routers.{{ nextcloud_service_name }}-push.middlewares={{ nextcloud_service_name }}-push-https
{% endif %}
networks:
{{ nextcloud_backend_network }}:
{{ nextcloud_traefik_network }}:
external: true
{% for net in nextcloud_extra_networks %}
{{ net }}:
external: true
{% endfor %}