version: '3.8'

services:
  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_DB: queueing_network
      POSTGRES_USER: queueuser
      POSTGRES_PASSWORD: queuepass
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U queueuser"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build: ./apps/backend
    ports:
      - "8000:8000"
    environment:
      DATABASE_URL: postgresql://queueuser:queuepass@postgres:5432/queueing_network
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - ./apps/backend:/app
    command: sh -c "alembic upgrade head && uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload"

  frontend:
    build: ./apps/web
    ports:
      - "5173:5173"
    volumes:
      - ./apps/web:/app
      - /app/node_modules
    command: npm run dev -- --host 0.0.0.0

volumes:
  postgres_data:
