services:
  app:
    depends_on:
      postgres:
        condition: service_healthy
    image: ghcr.io/logto-io/logto:${TAG-latest}
    entrypoint: ["sh", "-c", "npm run cli db seed -- --swe && npm start"]
    ports:
      - ${LOGTO_CORE_PORT:-3001}:3001
      - ${LOGTO_ADMIN_PORT:-3002}:3002
    environment:
      TRUST_PROXY_HEADER: 1
      DB_URL: postgres://logto:${LOGTO_POSTGRES_PASSWORD}@postgres:5432/logto
      ENDPOINT: ${LOGTO_ENDPOINT}
      ADMIN_ENDPOINT: ${LOGTO_ADMIN_ENDPOINT}
    volumes:
      - logto-connectors:/etc/logto/packages/core/connectors
    networks:
      logto_network:
  postgres:
    image: postgres:17-alpine
    user: postgres
    ports:
      - ${LOGTO_POSTGRES_PORT:-5432}:5432
    environment:
      POSTGRES_USER: logto
      POSTGRES_PASSWORD: ${LOGTO_POSTGRES_PASSWORD}
    healthcheck:
      test: ["CMD-SHELL", "pg_isready"]
      interval: 10s
      timeout: 5s
      retries: 5
    volumes:
      - postgres-data:/var/lib/postgresql/data
    networks:
      logto_network:

networks:
  logto_network:

volumes:
  logto-connectors:
  postgres-data:
