diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index f7a1c2b..b40c850 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,9 +1,11 @@ -name: Build and Deploy KCG AI Monitoring +name: Build and Deploy KCG AI Monitoring (Frontend) on: push: branches: - main + paths: + - 'frontend/**' jobs: build-and-deploy: @@ -18,20 +20,23 @@ jobs: node-version: '24' - name: Configure npm registry + working-directory: frontend run: | echo "registry=https://nexus.gc-si.dev/repository/npm-public/" > .npmrc echo "//nexus.gc-si.dev/repository/npm-public/:_auth=${{ secrets.NEXUS_NPM_AUTH }}" >> .npmrc - name: Install dependencies + working-directory: frontend run: npm ci --legacy-peer-deps - name: Build + working-directory: frontend run: npm run build - name: Deploy to server run: | mkdir -p /deploy/kcg-ai-monitoring rm -rf /deploy/kcg-ai-monitoring/* - cp -r dist/* /deploy/kcg-ai-monitoring/ - echo "Deployed at $(date '+%Y-%m-%d %H:%M:%S')" + cp -r frontend/dist/* /deploy/kcg-ai-monitoring/ + echo "Frontend deployed at $(date '+%Y-%m-%d %H:%M:%S')" ls -la /deploy/kcg-ai-monitoring/ diff --git a/CLAUDE.md b/CLAUDE.md index d668cbb..b200dad 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,12 +7,15 @@ ``` kcg-ai-monitoring/ ├── frontend/ # React 19 + TypeScript + Vite (UI) -├── backend/ # Spring Boot 3.x + Java 21 (자체 인증/권한/감사 + 분석 프록시) -├── database/ # PostgreSQL 마이그레이션 (Flyway) +├── backend/ # Spring Boot 3.x + Java 21 (인증/권한/감사 + 분석 API) +├── prediction/ # Python 3.9 + FastAPI (AIS 분석 엔진, 5분 주기) +├── database/ # PostgreSQL 마이그레이션 (Flyway V001~V013) │ └── migration/ +├── deploy/ # 배포 가이드 + 서버 설정 문서 ├── docs/ # 프로젝트 문서 (SFR, 아키텍처) +├── .gitea/ # Gitea Actions CI/CD (프론트 자동배포) ├── .claude/ # Claude Code 워크플로우 -├── .githooks/ # Git hooks (commit-msg, pre-commit, post-checkout) +├── .githooks/ # Git hooks └── Makefile # 통합 dev/build 명령 ``` @@ -75,6 +78,18 @@ make format # 프론트 prettier - 사용자: `kcg-app` - 스키마: `kcg` +## 배포 환경 + +| 서비스 | 서버 (SSH) | 포트 | 관리 | +|---|---|---|---| +| 프론트엔드 | rocky-211 | nginx 443 | Gitea Actions 자동배포 | +| 백엔드 | rocky-211 | 18080 | `systemctl restart kcg-ai-backend` | +| prediction | redis-211 | 18092 | `systemctl restart kcg-ai-prediction` | + +- **URL**: https://kcg-ai-monitoring.gc-si.dev +- **배포 상세**: `deploy/README.md` 참조 +- **CI/CD**: `.gitea/workflows/deploy.yml` (프론트만 자동, 백엔드/prediction 수동) + ## 권한 체계 좌측 탭(메뉴) = 권한 그룹, 내부 패널/액션 = 자식 자원, CRUD 단위 개별 제어. diff --git a/deploy/README.md b/deploy/README.md index 72fc4b6..3464433 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -1,11 +1,21 @@ # 배포 가이드 +## 접속 정보 + +| 항목 | URL / 경로 | +|---|---| +| **프론트엔드** | https://kcg-ai-monitoring.gc-si.dev | +| **백엔드 API** | https://kcg-ai-monitoring.gc-si.dev/api/* | +| **prediction API** | https://kcg-ai-monitoring.gc-si.dev/api/prediction/* | +| **데모 로그인** | admin / admin1234! (또는 DemoQuickLogin) | +| **DB** | `psql -h 211.208.115.83 -U kcg-app -d kcgaidb` (pw: Kcg2026ai) | + ## 서버 구성 -| 서버 | 호스트 | 역할 | 포트 | -|---|---|---|---| -| 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) | +| 서버 | SSH | IP | 역할 | 포트 | +|---|---|---|---|---| +| rocky-211 | `ssh rocky-211` | 211.208.115.83 | 프론트 + 백엔드 + nginx | 443, 18080 | +| redis-211 | `ssh redis-211` | 192.168.1.18 | prediction + Redis + Ollama | 18092, 6379, 11434 | ## 서비스 목록 @@ -161,3 +171,60 @@ PGPASSWORD='Kcg2026ai' psql -h 211.208.115.83 -U kcg-app -d kcgaidb | 5432 | PostgreSQL (kcgaidb, snpdb) | 211.208.115.83 | | 6379 | Redis | redis-211 | | 11434 | Ollama | redis-211 | + +## CI/CD + +### 프론트엔드 — Gitea Actions 자동배포 +- 워크플로우: `.gitea/workflows/deploy.yml` +- 트리거: `main` 브랜치 push, `frontend/**` 변경 시 +- 빌드: Node.js 24, `frontend/` 디렉토리에서 `npm ci && npm run build` +- 배포: `frontend/dist/` → `/deploy/kcg-ai-monitoring/` (Gitea runner mount) +- Gitea runner가 rocky-211에서 실행 중이므로 dist가 자동 배포됨 + +### 백엔드 — SSH 수동배포 +```bash +# 1. 로컬 빌드 +cd backend && ./mvnw clean package -DskipTests + +# 2. 서버 전송 +scp target/kcg-ai-backend-0.0.1-SNAPSHOT.jar \ + rocky-211:/devdata/services/kcg-ai-monitoring/backend/kcg-ai-backend.jar + +# 3. 재시작 +ssh rocky-211 "systemctl restart kcg-ai-backend" +``` + +### prediction — SSH 수동배포 +```bash +# 1. 파일 동기화 +rsync -avz --exclude='.venv' --exclude='__pycache__' --exclude='.env' --exclude='*.pyc' \ + prediction/ redis-211:/home/apps/kcg-ai-prediction/ + +# 2. 의존성 변경 시 +ssh redis-211 "cd /home/apps/kcg-ai-prediction && source venv/bin/activate && pip install -r requirements.txt" + +# 3. 재시작 +ssh redis-211 "systemctl restart kcg-ai-prediction" +``` + +## 서버 실행 경로 정리 + +### rocky-211 (211.208.115.83) +| 경로 | 용도 | +|---|---| +| `/devdata/services/kcg-ai-monitoring/dist/` | 프론트 빌드 산출물 (nginx root) | +| `/devdata/services/kcg-ai-monitoring/backend/kcg-ai-backend.jar` | 백엔드 실행 JAR | +| `/devdata/services/kcg-ai-monitoring/backend/application-prod.yml` | 백엔드 운영 설정 | +| `/etc/nginx/conf.d/kcg-ai-monitoring.conf` | nginx 프록시 설정 | +| `/etc/systemd/system/kcg-ai-backend.service` | 백엔드 systemd 서비스 | +| `/usr/lib/jvm/java-21-openjdk/bin/java` | Java 21 실행 경로 | + +### redis-211 (192.168.1.18) +| 경로 | 용도 | +|---|---| +| `/home/apps/kcg-ai-prediction/` | prediction 앱 디렉토리 | +| `/home/apps/kcg-ai-prediction/.env` | prediction 환경변수 | +| `/home/apps/kcg-ai-prediction/venv/` | Python 3.9 가상환경 | +| `/etc/systemd/system/kcg-ai-prediction.service` | prediction systemd 서비스 | +| `/home/apps/kcg-prediction/` | 기존 iran prediction (포트 8001) | +| `/home/apps/kcg-prediction-lab/` | 기존 lab prediction (포트 18091) |