name: athena-auth

services:
  postgres:
    image: postgres:16-bookworm
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${ATHENA_AUTH_DOCKER_POSTGRES_DB:-athena_auth}
      POSTGRES_USER: ${ATHENA_AUTH_DOCKER_POSTGRES_USER:-postgres}
      POSTGRES_PASSWORD: ${ATHENA_AUTH_DOCKER_POSTGRES_PASSWORD:-postgres}
    ports:
      - "${ATHENA_AUTH_DOCKER_POSTGRES_PORT:-5432}:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U ${ATHENA_AUTH_DOCKER_POSTGRES_USER:-postgres} -d ${ATHENA_AUTH_DOCKER_POSTGRES_DB:-athena_auth}
      interval: 5s
      timeout: 5s
      retries: 12
      start_period: 10s

  athena-auth:
    build:
      context: .
      dockerfile: Dockerfile
      args:
        APP_VERSION: ${ATHENA_AUTH_DOCKER_IMAGE_VERSION:-1.11.0}
    init: true
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    ports:
      - "${ATHENA_AUTH_DOCKER_PORT:-3000}:3000"
    environment:
      DATABASE_URL: postgresql://${ATHENA_AUTH_DOCKER_POSTGRES_USER:-postgres}:${ATHENA_AUTH_DOCKER_POSTGRES_PASSWORD:-postgres}@postgres:5432/${ATHENA_AUTH_DOCKER_POSTGRES_DB:-athena_auth}
      DATABASE_KEY: ${ATHENA_AUTH_DOCKER_DATABASE_KEY:-}
      JWT_SECRET: ${ATHENA_AUTH_DOCKER_JWT_SECRET:-local-development-jwt-secret-change-me-1234567890}
      HOST: 0.0.0.0
      PORT: 3000
      RUST_LOG: ${ATHENA_AUTH_DOCKER_RUST_LOG:-info}
      BASE_URL: ${ATHENA_AUTH_DOCKER_BASE_URL:-http://localhost:3000}
      AUTH_BASE_PATH: ${ATHENA_AUTH_DOCKER_AUTH_BASE_PATH:-/api/auth}
      PUBLIC_AUTH_BASE_PATH: ${ATHENA_AUTH_DOCKER_PUBLIC_AUTH_BASE_PATH:-/api/auth}
      PRIMARY_TRUSTED_ORIGIN: ${ATHENA_AUTH_DOCKER_PRIMARY_TRUSTED_ORIGIN:-http://localhost:3000}
      PASSKEY_ORIGIN: ${ATHENA_AUTH_DOCKER_PASSKEY_ORIGIN:-http://localhost:3000}
      PASSKEY_RP_ID: ${ATHENA_AUTH_DOCKER_PASSKEY_RP_ID:-localhost}
      PASSKEY_RP_NAME: ${ATHENA_AUTH_DOCKER_PASSKEY_RP_NAME:-Athena Auth}
      PASSKEY_ALLOW_INSECURE: ${ATHENA_AUTH_DOCKER_PASSKEY_ALLOW_INSECURE:-true}
      ATHENA_AUTH_CONFIG_FILE: /app/config.yaml

volumes:
  postgres_data:
