services:
  app:
    build:
      context: .
      dockerfile: Dockerfile
    environment:
      NODE_ENV: production
      DATABASE_URL: postgresql://postgres:postgres@db:5432/askqien
      AUTH_SECRET: ${AUTH_SECRET}
      NEXTAUTH_URL: http://localhost:3000
      EMAIL_SERVER_HOST: ${EMAIL_SERVER_HOST:-mailpit}
      EMAIL_SERVER_PORT: ${EMAIL_SERVER_PORT:-1025}
      EMAIL_FROM: ${EMAIL_FROM:-noreply@ask-qien.local}
      ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-}
      INNGEST_EVENT_KEY: ${INNGEST_EVENT_KEY:-}
      INNGEST_SIGNING_KEY: ${INNGEST_SIGNING_KEY:-}
      TENANT_CONFIG_PATH: ./tenant.config.yaml
    ports:
      - "3000:3000"
    depends_on:
      db:
        condition: service_healthy

  db:
    image: pgvector/pgvector:pg16
    restart: unless-stopped
    environment:
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: askqien
      POSTGRES_USER: postgres
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d askqien"]
      interval: 5s
      timeout: 5s
      retries: 10

  mailpit:
    image: axllent/mailpit:latest
    ports:
      - "1025:1025"
      - "8025:8025"

volumes:
  pgdata:
