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

  notifuse:
    image: notifuse/notifuse:latest
    restart: unless-stopped
    depends_on:
      - db
    environment:
      # Root user configuration
      ROOT_EMAIL: ${ROOT_EMAIL}

      # API configuration
      API_ENDPOINT: ${API_ENDPOINT}

      # Database configuration
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: postgres
      DB_PASSWORD: postgres
      DB_PREFIX: notifuse
      DB_NAME: postgres
      DB_SSLMODE: disable

      # Secret key for authentication (auto-generated)
      SECRET_KEY: ${SECRET_KEY}

      # Server configuration
      SERVER_PORT: 8080
      SERVER_HOST: 0.0.0.0
      ENVIRONMENT: production
    volumes:
      - notifuse_data:/app/data
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:8080/healthz"]
      interval: 10s
      timeout: 5s
      retries: 3
      start_period: 10s

volumes:
  db_data: {}
  notifuse_data: {}
