services:
  db:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: alzar
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
      POSTGRES_DB: alzar_website
    volumes:
      - alzar_pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U alzar -d alzar_website"]
      interval: 5s
      timeout: 5s
      retries: 10

  app:
    build: .
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql://alzar:${POSTGRES_PASSWORD:-changeme}@db:5432/alzar_website
      DATABASE_SSL: "false"
      JWT_SECRET: ${JWT_SECRET:?set JWT_SECRET in .env}
      NODE_ENV: production
      PORT: "3000"
      SMTP_HOST: ${SMTP_HOST:-}
      SMTP_PORT: ${SMTP_PORT:-587}
      SMTP_USER: ${SMTP_USER:-}
      SMTP_PASS: ${SMTP_PASS:-}
      OWNER_EMAIL: ${OWNER_EMAIL:-}
      FROM_EMAIL: ${FROM_EMAIL:-}
    ports:
      - "3000:3000"

volumes:
  alzar_pgdata:
