version: '3.8'

services:
  postgres:
    image: postgres:17-alpine
    container_name: fraiseql-postgres
    ports:
      - "5433:5432"
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: postgres
      POSTGRES_DB: fraiseql_test
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./tests/fixtures/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
      - ./tests/fixtures/seed_data.sql:/docker-entrypoint-initdb.d/02-seed.sql
      - ./tests/fixtures/pg_hba.conf:/docker-entrypoint-initdb.d/00-pg_hba.conf
    networks:
      - fraiseql-network

  # Optional: Adminer for database inspection (http://localhost:8081)
  adminer:
    image: adminer:latest
    container_name: fraiseql-adminer
    ports:
      - "8081:8080"
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      ADMINER_DEFAULT_SERVER: postgres
    networks:
      - fraiseql-network

networks:
  fraiseql-network:
    driver: bridge

volumes:
  postgres_data:
