# Docker Compose for Nextcloud 28 with PostgreSQL 16
# Usage: docker compose -f docker/postgres/docker-compose.yml up -d
#
# Part of Issue #192 (database portability).

services:
  db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: nextcloud
    volumes:
      - pg_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U nextcloud"]
      interval: 10s
      timeout: 5s
      retries: 5

  nextcloud:
    image: nextcloud:28-apache
    restart: unless-stopped
    ports:
      - "8081:80"
    environment:
      POSTGRES_HOST: db
      POSTGRES_DB: nextcloud
      POSTGRES_USER: nextcloud
      POSTGRES_PASSWORD: nextcloud
      NEXTCLOUD_ADMIN_USER: admin
      NEXTCLOUD_ADMIN_PASSWORD: admin
      NEXTCLOUD_TRUSTED_DOMAINS: "localhost"
    volumes:
      - nc_data:/var/www/html
      - ../../:/app-src:ro
    depends_on:
      db:
        condition: service_healthy

volumes:
  pg_data:
  nc_data:
