services:
  # ── Postgres (optional; remove if using SQLite) ──────────────────────────────
  postgres:
    image: postgres:18-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: ladon
      POSTGRES_PASSWORD: changeme
      POSTGRES_DB: ladon
    volumes:
      - pgdata:/var/lib/postgresql
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ladon -d ladon"]
      interval: 5s
      timeout: 5s
      retries: 10

  # ── ladon pool daemon ─────────────────────────────────────────────────────────
  ladon:
    image: ${LADON_IMAGE:?set LADON_IMAGE to the published container image}
    restart: unless-stopped
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      # Provide the mnemonic via the environment; never bake secrets into the image.
      LADON_MNEMONIC: "${LADON_MNEMONIC:?set LADON_MNEMONIC}"
      # Point the Postgres URL at the service above.
      DATABASE_URL: "postgres://ladon:changeme@postgres:5432/ladon"
      # Adjust log verbosity: error | warn | info | debug | trace
      RUST_LOG: "ladon=info"
    volumes:
      - ./Config.toml:/app/Config.toml:ro
      # Only needed for the SQLite backend:
      # - ./data:/app/data

volumes:
  pgdata:
