services:
  # ----------------------------------------
  # 1. Frontend (Nginx 정적 호스팅)
  # ----------------------------------------
  frontend:
    container_name: ${PROJECT_NAME}-frontend
    build:
      context: ./${FRONTEND_DIR}
      dockerfile: Dockerfile
      args:
        - BUILD_MODE=${BUILD_MODE}
        - VITE_API_BASE_URL=${FRONT_API_URL}
    expose:
      - "80"
    environment:
      - NODE_ENV=${APP_ENV}
    restart: unless-stopped
    networks:
      - app-network
      - proxy
    # depends_on:
    #   - backend
    healthcheck:
      test: ["CMD-SHELL", "wget -qO- http://localhost:80/ || exit 1"]
      interval: 30s
      timeout: 5s
      retries: 5
      start_period: 10s
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512m

  # ----------------------------------------
  # 2. Backend (HTTP API & WebSocket 통합)
  # ----------------------------------------
  # backend:
  #   container_name: ${PROJECT_NAME}-backend
  #   build:
  #     context: ./${BACKEND_DIR}
  #     dockerfile: Dockerfile
  #   expose:
  #     - "${BACKEND_PORT}"
  #     - "${WEBSOCKET_PORT}"
  #   env_file:
  #     - ./${BACKEND_DIR}/.env.${APP_ENV}
  #   environment:
  #     - NODE_ENV=${APP_ENV}
  #     - PORT=${BACKEND_PORT}
  #     - WEBSOCKET_PORT=${WEBSOCKET_PORT}
  #     - CORS_ORIGIN=${CORS_ORIGIN}
  #     - DB_HOST=db
  #     - DB_PORT=5432
  #     - DB_USER=${DB_USER}
  #     - DB_PASSWORD=${DB_PASSWORD}
  #     - DB_NAME=${DB_NAME}
  #     - REDIS_HOST=redis
  #     - REDIS_PORT=6379
  #     - REDIS_PASSWORD=${REDIS_PASSWORD}
  #   restart: unless-stopped
  #   networks:
  #     - app-network
  #     - proxy
  #   depends_on:
  #     db:
  #       condition: service_healthy
  #     redis:
  #       condition: service_healthy
  #   healthcheck:
  #     test: ["CMD-SHELL", "wget -qO- http://localhost:${BACKEND_PORT}/ || exit 1"]
  #     interval: 30s
  #     timeout: 5s
  #     retries: 5
  #     start_period: 30s
  #   deploy:
  #     resources:
  #       limits:
  #         cpus: '1.0'
  #         memory: 1g

  # ----------------------------------------
  # 3. Database (PostgreSQL) — 내부 네트워크 전용
  # ----------------------------------------
  # db:
  #   container_name: ${PROJECT_NAME}-db
  #   image: ${DB_IMAGE}
  #   expose:
  #     - "5432"
  #   environment:
  #     POSTGRES_USER: ${DB_USER}
  #     POSTGRES_PASSWORD: ${DB_PASSWORD}
  #     POSTGRES_DB: ${DB_NAME}
  #   volumes:
  #     - ./db-data:/var/lib/postgresql/data
  #   restart: always
  #   networks:
  #     - app-network
  #   healthcheck:
  #     test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5
  #     start_period: 10s
  #   deploy:
  #     resources:
  #       limits:
  #         cpus: '0.5'
  #         memory: 512m
  #   labels:
  #     - "com.centurylinklabs.watchtower.enable=true"

  # ----------------------------------------
  # 4. Redis — 내부 네트워크 전용
  # ----------------------------------------
  # redis:
  #   container_name: ${PROJECT_NAME}-redis
  #   image: ${REDIS_IMAGE}
  #   command: redis-server --requirepass ${REDIS_PASSWORD}
  #   expose:
  #     - "6379"
  #   volumes:
  #     - ./redis-data:/data
  #   restart: always
  #   networks:
  #     - app-network
  #   healthcheck:
  #     test: ["CMD-SHELL", "redis-cli -a ${REDIS_PASSWORD} ping | grep PONG"]
  #     interval: 10s
  #     timeout: 5s
  #     retries: 5
  #     start_period: 5s
  #   deploy:
  #     resources:
  #       limits:
  #         cpus: '0.25'
  #         memory: 256m
  #   labels:
  #     - "com.centurylinklabs.watchtower.enable=true"

networks:
  app-network:
    driver: bridge
  proxy:
    external: true