services:
  shade-prekey:
    image: shade-prekey-server:latest
    build:
      context: ../..
      dockerfile: packages/shade-server/Dockerfile
    restart: unless-stopped
    ports:
      - "3900:3900"
    environment:
      - PORT=3900
      - SHADE_PREKEY_PG_URL=postgres://shade:shade@postgres:5432/shade
      - SHADE_LOG_LEVEL=info
    depends_on:
      postgres:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-fsS", "http://localhost:3900/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  postgres:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_USER=shade
      - POSTGRES_PASSWORD=shade
      - POSTGRES_DB=shade
    volumes:
      - shade-pg-data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U shade"]
      interval: 5s
      timeout: 5s
      retries: 5

volumes:
  shade-pg-data:
