version: '3.8'

services:
  api:
    build:
      context: .
      dockerfile: apps/api/Dockerfile.dev
    env_file:
      - .env.development
    environment:
      - NODE_ENV=development
    ports:
      - "3000:3000"
      - "9229:9229"
    depends_on:
      db:
        condition: service_healthy
    networks:
      - gridpilot-network
    restart: unless-stopped

  website:
    build:
      context: .
      dockerfile: apps/website/Dockerfile.dev
    env_file:
      - .env.development
    environment:
      - NEXT_TELEMETRY_DISABLED=1
    ports:
      - "3001:3000"
    networks:
      - gridpilot-network
    restart: unless-stopped

  db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_DB=${POSTGRES_DB:-gridpilot_db}
      - POSTGRES_USER=${POSTGRES_USER:-user}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-password}
    ports:
      - "5432:5432"
    volumes:
      - dev_db_data:/var/lib/postgresql/data
    networks:
      - gridpilot-network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-user} -d ${POSTGRES_DB:-gridpilot_db}"]
      interval: 5s
      timeout: 5s
      retries: 5

networks:
  gridpilot-network:
    driver: bridge

volumes:
  dev_db_data:
