feat: 배포 환경 구성 + 로컬 프록시 서버 전환

rocky-211 백엔드 배포:
- /devdata/services/kcg-ai-monitoring/backend/ (JAR + application-prod.yml)
- systemd kcg-ai-backend.service (포트 18080)

redis-211 prediction 배포:
- /home/apps/kcg-ai-prediction/ (포트 18092)
- systemd kcg-ai-prediction.service

nginx 프록시 (rocky-211):
- /api/ → localhost:18080 (Spring Boot)
- /api/prediction/ → 192.168.1.18:18092 (prediction)
- /api/prediction-chat → SSE 프록시

로컬 개발:
- vite 프록시 기본값을 서버(kcg-ai-monitoring.gc-si.dev)로 변경
- 로컬 백엔드 사용 시: VITE_API_PROXY=http://localhost:8080

deploy/README.md: 배포 가이드 문서화

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
htlee 2026-04-07 13:38:45 +09:00
부모 6ac9184016
커밋 2cb8414676
2개의 변경된 파일165개의 추가작업 그리고 1개의 파일을 삭제

163
deploy/README.md Normal file
파일 보기

@ -0,0 +1,163 @@
# 배포 가이드
## 서버 구성
| 서버 | 호스트 | 역할 | 포트 |
|---|---|---|---|
| rocky-211 | 211.208.115.83 (ssh rocky-211) | 프론트엔드 + 백엔드 + nginx | 443(nginx), 18080(backend) |
| redis-211 | 192.168.1.18 (ssh redis-211) | prediction 분석 + Redis + Ollama | 18092(prediction), 8001(기존), 6379(redis) |
## 서비스 목록
### rocky-211
| 서비스 | systemd | 포트 | 로그 |
|---|---|---|---|
| 백엔드 (Spring Boot) | `kcg-ai-backend.service` | 18080 | `journalctl -u kcg-ai-backend -f` |
| nginx | `nginx.service` | 80/443 | `/var/log/nginx/` |
### redis-211
| 서비스 | systemd | 포트 | 로그 |
|---|---|---|---|
| kcg-ai-prediction | `kcg-ai-prediction.service` | 18092 | `journalctl -u kcg-ai-prediction -f` |
| kcg-prediction (기존 iran) | `kcg-prediction.service` | 8001 | `journalctl -u kcg-prediction -f` |
| kcg-prediction-lab | `kcg-prediction-lab.service` | 18091 | `journalctl -u kcg-prediction-lab -f` |
## 디렉토리 구조
### rocky-211
```
/devdata/services/kcg-ai-monitoring/
├── dist/ # 프론트엔드 빌드 산출물
│ ├── index.html
│ └── assets/
├── backend/
│ ├── kcg-ai-backend.jar # Spring Boot 실행 JAR
│ └── application-prod.yml # 운영 설정
```
### redis-211
```
/home/apps/kcg-ai-prediction/ # 신규 (kcgaidb 연결)
├── .env # 환경변수
├── venv/ # Python 가상환경
├── main.py # FastAPI 진입점
├── algorithms/ # 14개 분석 알고리즘
├── pipeline/ # 7단계 분류 파이프라인
├── output/ # 이벤트/통계/KPI 출력 모듈
├── cache/ # vessel_store
├── db/ # DB 어댑터
└── ...
```
## nginx 프록시 설정
파일: `/etc/nginx/conf.d/kcg-ai-monitoring.conf` (rocky-211)
```
kcg-ai-monitoring.gc-si.dev (443)
├── / → /devdata/services/kcg-ai-monitoring/dist/ (SPA)
├── /api/ → http://127.0.0.1:18080 (Spring Boot)
├── /api/prediction/ → http://192.168.1.18:18092 (prediction)
└── /api/prediction-chat → http://192.168.1.18:18092 (SSE)
```
## 배포 방법
### 프론트엔드 배포
```bash
# 로컬에서 빌드
cd frontend && npx vite build
# 서버에 전송
rsync -avz dist/ rocky-211:/devdata/services/kcg-ai-monitoring/dist/
```
### 백엔드 배포
```bash
# 로컬에서 JAR 빌드
cd backend && ./mvnw clean package -DskipTests
# 서버에 전송
scp target/kcg-ai-backend-0.0.1-SNAPSHOT.jar rocky-211:/devdata/services/kcg-ai-monitoring/backend/kcg-ai-backend.jar
# 서버에서 재시작
ssh rocky-211 "systemctl restart kcg-ai-backend"
# 로그 확인
ssh rocky-211 "journalctl -u kcg-ai-backend -f"
```
### prediction 배포
```bash
# 파일 동기화 (venv 제외)
rsync -avz --exclude='.venv' --exclude='__pycache__' --exclude='.env' --exclude='*.pyc' \
prediction/ redis-211:/home/apps/kcg-ai-prediction/
# 서버에서 재시작
ssh redis-211 "systemctl restart kcg-ai-prediction"
# 로그 확인
ssh redis-211 "journalctl -u kcg-ai-prediction -f"
```
### 의존성 변경 시 (prediction)
```bash
ssh redis-211 "cd /home/apps/kcg-ai-prediction && source venv/bin/activate && pip install -r requirements.txt"
ssh redis-211 "systemctl restart kcg-ai-prediction"
```
## 로컬 개발 설정
### 기본 (서버 프록시)
```bash
cd frontend && npm run dev
# → /api 요청이 https://kcg-ai-monitoring.gc-si.dev로 프록시됨
```
### 로컬 백엔드 사용 시
```bash
VITE_API_PROXY=http://localhost:8080 npm run dev
# 또는 backend와 함께:
make dev # frontend + backend 동시 실행
```
## 서비스 관리
```bash
# 상태 확인
ssh rocky-211 "systemctl status kcg-ai-backend"
ssh redis-211 "systemctl status kcg-ai-prediction"
# 재시작
ssh rocky-211 "systemctl restart kcg-ai-backend"
ssh redis-211 "systemctl restart kcg-ai-prediction"
# 로그 (실시간)
ssh rocky-211 "journalctl -u kcg-ai-backend -f"
ssh redis-211 "journalctl -u kcg-ai-prediction -f"
# health check
curl -s https://kcg-ai-monitoring.gc-si.dev/actuator/health
curl -s http://192.168.1.18:18092/health # redis-211 내부
```
## DB 접속
```bash
PGPASSWORD='Kcg2026ai' psql -h 211.208.115.83 -U kcg-app -d kcgaidb
# 스키마: kcg, 테이블 37개
```
## 포트 정리
| 포트 | 서비스 | 서버 |
|---|---|---|
| 443 | nginx (HTTPS) | rocky-211 |
| 18080 | kcg-ai-backend (Spring Boot) | rocky-211 |
| 18092 | kcg-ai-prediction (FastAPI) | redis-211 |
| 8001 | kcg-prediction (기존 iran) | redis-211 |
| 18091 | kcg-prediction-lab | redis-211 |
| 5432 | PostgreSQL (kcgaidb, snpdb) | 211.208.115.83 |
| 6379 | Redis | redis-211 |
| 11434 | Ollama | redis-211 |

파일 보기

@ -22,8 +22,9 @@ export default defineConfig({
port: 5173,
proxy: {
'/api': {
target: 'http://localhost:8080',
target: process.env.VITE_API_PROXY ?? 'https://kcg-ai-monitoring.gc-si.dev',
changeOrigin: true,
secure: false,
},
},
},