version: '3.8'

services:
  # PostgreSQL Database
  postgres:
    image: postgres:15-alpine
    container_name: dramaling_postgres
    environment:
      POSTGRES_DB: dramaling_dev
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./backend/scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
    networks:
      - dramaling_network

  # Redis Cache
  redis:
    image: redis:7-alpine
    container_name: dramaling_redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    networks:
      - dramaling_network

  # .NET API (Development)
  api:
    build:
      context: ./backend
      dockerfile: DramaLing.API/Dockerfile.dev
    container_name: dramaling_api
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:5000
      - ConnectionStrings__DefaultConnection=Host=postgres;Port=5432;Database=dramaling_dev;Username=postgres;Password=password
      - ConnectionStrings__Redis=redis:6379
    ports:
      - "5000:5000"
    depends_on:
      - postgres
      - redis
    volumes:
      - ./backend:/app
    networks:
      - dramaling_network
    restart: unless-stopped

volumes:
  postgres_data:
  redis_data:

networks:
  dramaling_network:
    driver: bridge