# Docker Compose configuration for local development

services:
  db:
    image: postgres:15-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    environment:
      - POSTGRES_DB=[[ project_slug ]]
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    ports:
      - "${DB_PORT:-5440}:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 5s
      timeout: 5s
      retries: 5

  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./backend:/app
    ports:
      - "${BACKEND_PORT:-8000}:8000"
    environment:
      - DEBUG=1
      - DJANGO_SETTINGS_MODULE=config.settings.local
      - DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,[::1]
      - DATABASE_URL=postgres://postgres:password@db:5432/[[ project_slug ]]
    depends_on:
      db:
        condition: service_healthy

  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile.dev
    command: npm run dev -- --host 0.0.0.0
    volumes:
      - ./frontend:/app
      - /app/node_modules
    ports:
      - "${FRONTEND_PORT:-3000}:5173"
    environment:
      - VITE_API_URL=http://localhost:${BACKEND_PORT:-8000}/api
    depends_on:
      - backend

volumes:
  postgres_data:
