# ==============================================
# Docker Compose для DEV окружения
# ==============================================

services:
  db:
    image: postgres:16-alpine
    container_name: platform_dev_db
    restart: unless-stopped
    environment:
      POSTGRES_DB: platform_dev_db
      POSTGRES_USER: platform_dev_user
      POSTGRES_PASSWORD: platform_dev_password
    ports:
      - "5433:5432"
    volumes:
      - dev_postgres_data:/var/lib/postgresql/data
    networks:
      - dev_network

  redis:
    image: redis:7-alpine
    container_name: platform_dev_redis
    restart: unless-stopped
    ports:
      - "6380:6379"
    volumes:
      - dev_redis_data:/data
    networks:
      - dev_network

  web:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: platform_dev_web
    restart: unless-stopped
    command: sh -c "python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 4 --threads 2"
    environment:
      - DEBUG=True
      - SECRET_KEY=dev_secret_key
      - DATABASE_URL=postgresql://platform_dev_user:platform_dev_password@db:5432/platform_dev_db
      - REDIS_URL=redis://redis:6379/0
    ports:
      - "8124:8000"
    volumes:
      - ./backend:/app
    depends_on:
      - db
      - redis
    networks:
      - dev_network

  nginx:
    image: nginx:alpine
    container_name: platform_dev_nginx
    restart: unless-stopped
    ports:
      - "8081:80"
    volumes:
      - ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
    depends_on:
      - web
    networks:
      - dev_network

  front_material:
    build:
      context: ./front_material
      dockerfile: Dockerfile
    container_name: platform_dev_front_material
    restart: unless-stopped
    ports:
      - "3002:3000"
    networks:
      - dev_network

  yjs-whiteboard:
    build:
      context: ./yjs-whiteboard-server
      dockerfile: Dockerfile
    container_name: platform_dev_yjs_whiteboard
    restart: unless-stopped
    ports:
      - "1235:1234"
    networks:
      - dev_network

  excalidraw:
    build:
      context: ./excalidraw-server
      dockerfile: Dockerfile
    container_name: platform_dev_excalidraw
    restart: unless-stopped
    ports:
      - "3003:3001"
    networks:
      - dev_network

  whiteboard:
    build:
      context: ./whiteboard-server
      dockerfile: Dockerfile
    container_name: platform_dev_whiteboard
    restart: unless-stopped
    ports:
      - "8082:8080"
    networks:
      - dev_network

volumes:
  dev_postgres_data:
  dev_redis_data:

networks:
  dev_network:
    driver: bridge
