#!/bin/bash

echo "============================================"
echo "WACE 솔루션 - 백엔드 (Node.js) 시작"
echo "============================================"

echo ""
echo "1. Docker 이미지 빌드 중..."
docker-compose -f docker/dev/docker-compose.backend.mac.yml build

echo ""
echo "2. 기존 백엔드 컨테이너 정리 중..."
docker-compose -f docker/dev/docker-compose.backend.mac.yml down -v

echo ""
echo "3. Docker 네트워크 생성 중..."
docker network create pms-network 2>/dev/null || echo "네트워크가 이미 존재합니다."

echo ""
echo "4. 백엔드 컨테이너 시작 중..."
docker-compose -f docker/dev/docker-compose.backend.mac.yml up -d

echo ""
echo "5. 서비스 상태 확인 중..."
sleep 8

echo ""
echo "============================================"
echo "백엔드 서비스가 시작되었습니다!"
echo "============================================"
echo ""
echo "[DATABASE] PostgreSQL: http://39.117.244.52:11132"
echo "[BACKEND]  Node.js API: http://localhost:8080/api"
echo ""
echo "상태 확인: docker-compose -f docker/dev/docker-compose.backend.mac.yml ps"
echo "로그 확인: docker-compose -f docker/dev/docker-compose.backend.mac.yml logs -f"
echo "중지하기:  docker-compose -f docker/dev/docker-compose.backend.mac.yml down"
echo ""
echo "============================================"

read -p "계속하려면 아무 키나 누르세요..." 