# Smoke-test compose. Stands the API + Postgres up in isolation,
# exercises a mint, tears everything down (volume included). Never
# meant for production — for that see docs/SETUP-LICENSE-SERVER.md.
#
# Ports map to 127.0.0.1 only so it can run on a host that already
# binds 5432 / 8090 to something else.

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: dt_test
      POSTGRES_USER: dt_test
      POSTGRES_PASSWORD: test_pw
    ports:
      - "127.0.0.1:15432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dt_test -d dt_test"]
      interval: 2s
      timeout: 2s
      retries: 20

  api:
    build:
      context: ..
      dockerfile: server/Dockerfile
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      DATABASE_URL: postgresql+psycopg://dt_test:test_pw@postgres:5432/dt_test
      DATATOOLS_ADMIN_TOKEN: test-admin-token
      GUMROAD_WEBHOOK_SECRET: test-gumroad-secret
      # No DATATOOLS_LICENSE_PRIVKEY — falls back to the in-tree
      # dev keypair, matching what the desktop dev build expects.
      # No POSTMARK_TOKEN — falls back to LoggingEmailService.
    ports:
      - "127.0.0.1:18090:8000"
    healthcheck:
      test: ["CMD", "curl", "--fail", "--silent", "http://localhost:8000/health"]
      interval: 5s
      timeout: 3s
      retries: 10
