version: '3.8'

services:
  # 개발용 Nginx
  nginx:
    build: ./nginx
    container_name: document-server-nginx-dev
    ports:
      - "24100:80"
    volumes:
      - ./frontend:/usr/share/nginx/html
      - ./uploads:/usr/share/nginx/html/uploads
      - ./nginx/nginx.dev.conf:/etc/nginx/nginx.conf
    depends_on:
      - backend
    networks:
      - document-network

  # 개발용 Backend (핫 리로드)
  backend:
    build: 
      context: ./backend
      dockerfile: Dockerfile.dev
    container_name: document-server-backend-dev
    ports:
      - "24102:8000"
    volumes:
      - ./uploads:/app/uploads
      - ./backend:/app
    environment:
      - DATABASE_URL=postgresql://docuser:docpass@database:5432/document_db
      - PAPERLESS_URL=${PAPERLESS_URL:-http://localhost:8000}
      - PAPERLESS_TOKEN=${PAPERLESS_TOKEN:-}
      - DEBUG=true
      - RELOAD=true
    depends_on:
      - database
    networks:
      - document-network

  # 개발용 데이터베이스 (데이터 영속성 없음)
  database:
    image: postgres:15-alpine
    container_name: document-server-db-dev
    ports:
      - "24101:5432"
    environment:
      - POSTGRES_DB=document_db
      - POSTGRES_USER=docuser
      - POSTGRES_PASSWORD=docpass
    volumes:
      - ./database/init:/docker-entrypoint-initdb.d
    networks:
      - document-network

  # 개발용 Redis
  redis:
    image: redis:7-alpine
    container_name: document-server-redis-dev
    ports:
      - "24103:6379"
    networks:
      - document-network
    command: redis-server

networks:
  document-network:
    driver: bridge
