version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: upg
      POSTGRES_USER: upg
      POSTGRES_PASSWORD: upg
    ports:
      - "5433:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
      - ../migrations:/docker-entrypoint-initdb.d
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U upg"]
      interval: 5s
      timeout: 5s
      retries: 5

  upg-cloud:
    build:
      context: ..
      dockerfile: docker/Dockerfile
    depends_on:
      postgres:
        condition: service_healthy
    environment:
      UPG_DATABASE_URL: postgres://upg:upg@postgres:5432/upg
    stdin_open: true

volumes:
  pgdata:
