-
Notifications
You must be signed in to change notification settings - Fork 0
Server-develop(구축) #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
7ea6947
2f6b9b9
80e86e7
d6ca38c
721127d
04df98d
a81f4dd
75364df
ea9063d
08ac5c5
1bd9aaf
2d5cd84
736c281
19691c4
084b54b
5c540e1
acb1a3f
2c0f2ef
6e01d9f
4afcd22
d20bad4
afcafe9
4b304b1
cad71ab
c804899
d19b015
4510862
3f27b10
c368d9d
91ca61c
80679e0
f55d1c0
80a30a4
9709a95
a3e12d1
773052e
85134ca
ccad3f5
2700f93
8cfcf38
69acb22
211bb1a
09bdd59
e994806
6553bba
e159f63
4bc8530
1e5596e
1324b01
afe3510
a5ddd43
60e6147
b607d7b
bce48c7
3f832b2
8ffc03a
ac732a7
795a578
c3c4b5b
f401ccd
05b959a
979d439
5f8d48c
6a35bb6
e01118c
b16cd24
e60c666
ebdf75e
01cdd1b
2afbe19
84f54fc
85b9b4e
7b1b8e3
44987dd
be75296
71e6adb
ea52fdc
fc876fe
b75df3f
7de4ff9
9ce860a
d4f2294
3735a5d
3975850
6d9a20d
f5bd50e
e154f6f
c0d4d0f
be2cd10
4c7fc99
93ac922
6024617
ddc3f9a
2cd71e5
db31e30
17bb2fa
5c96f9c
924af97
ac8fcf0
e7c8837
2bce1da
3605964
8be53a7
cc5af6b
0dbd3b5
727ff14
21e7634
fd497b6
e4cc6af
41fce49
64eccf1
a4edf4a
f0d5b06
df8df92
17564d0
907543a
706e6db
9c31a7e
325329c
87a9f45
20a79ce
eb0d9cc
c3999b5
b161c00
af50c3a
542d92d
3fec21d
b5b48d8
443ed5c
19459e5
b622258
277dd50
60a9b93
6e4f512
6129463
cd331af
bad5668
0d5dcf1
0bf9078
b9a0af5
f3a9154
064ca7b
c98755e
509b70a
24b7d07
1f4c156
4678424
d7ca9d2
329dbf7
76341b3
f35897c
fd6d703
8b12781
23a3e97
51c318a
7b0a996
bde301d
0323d96
fb5067b
a0623be
361d22a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| MYSQL_ROOT_PASSWORD=veriq123 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Veri-Q Develop Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "develop", "feat/KD-12" ] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| steps: | ||
| - name: SSH Remote Commands | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.GCP_IP }} | ||
| username: ${{ secrets.GCP_USER }} | ||
| key: ${{ secrets.GCP_SSH_KEY }} | ||
| command_timeout: 50m | ||
| script: | | ||
| cd /opt/main-server | ||
| git pull origin develop | ||
| chmod +x gradlew | ||
| sudo ./gradlew bootJar | ||
| sudo docker-compose build --no-cache | ||
| sudo docker-compose up --build -d | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,3 +14,4 @@ out/ | |
| .gradle/ | ||
| # 비밀번호가 담긴 설정 파일은 제외 | ||
| src/main/resources/application.yml | ||
| .env | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # 1단계: 빌드 스테이지 | ||
| FROM gradle:jdk21 AS build | ||
| WORKDIR /app | ||
| COPY . . | ||
|
|
||
| # 빌드 인자로 메인 클래스를 받습니다 (기본값은 Gateway) | ||
| ARG MAIN_CLASS=com.veriq.veriqgateway.VeriQGatewayApplication | ||
|
|
||
| # 지정된 메인 클래스로 빌드하도록 명령 | ||
| RUN gradle clean build -x test -PmainClass=${MAIN_CLASS} | ||
|
|
||
| # 2단계: 실행 스테이지 | ||
| FROM eclipse-temurin:21-jdk | ||
| RUN groupadd -r appgroup && useradd -r -g appgroup appuser | ||
| WORKDIR /app | ||
|
|
||
| # 빌드된 jar 파일 가져오기 | ||
| COPY --from=build /app/build/libs/*.jar /app/app.jar | ||
|
|
||
| RUN chown -R appuser:appgroup /app | ||
| USER appuser | ||
| ENTRYPOINT ["java", "-jar", "/app/app.jar"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,301 @@ | ||
| add file ".gitignore" | ||
| # Veri-Q 서버 접속 및 개발 가이드 | ||
| 구축한 GCP 서버 인프라를 사용하기 위한 가이드입니다. | ||
|
|
||
| ## 🌐 서버 정보 | ||
| - **공통 외부 IP**: `34.64.218.236` | ||
| - **관리자 계정**: `root` (DB 접속 시 사용) | ||
| * **서버 사용자**: `sk38808738` (SSH 접속 시 사용) | ||
|
Comment on lines
+5
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 보안: 민감한 정보가 문서에 노출되어 있습니다. README에 실제 서버 IP 주소( 🔒 플레이스홀더 사용 제안 ## 🌐 서버 정보
-- **공통 외부 IP**: `34.64.218.236`
+- **공통 외부 IP**: `<GCP_EXTERNAL_IP>` # 팀 채널에서 확인
- **관리자 계정**: `root` (DB 접속 시 사용)
-* **서버 사용자**: `sk38808738` (SSH 접속 시 사용)
+* **서버 사용자**: `<SSH_USERNAME>` (SSH 접속 시 사용)비밀번호도 Also applies to: 132-133 🤖 Prompt for AI Agents |
||
|
|
||
| ### 서비스별 포트 | ||
| | 서비스 | 포트 | 용도 | | ||
| | :--- | :--- | :--- | | ||
| | **Spring BE1** | `8081` | Gateway 서버 | | ||
| | **Spring BE3** | `8083` | Platform/Data Hub 서버 | | ||
| | **FastAPI** | `8000` | 분석 엔진 서버 | | ||
| | **MySQL** | `3306` | 데이터베이스 | | ||
| | **Redis** | `6379` | 캐시 서버 | | ||
|
Comment on lines
+10
to
+16
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Markdownlint(MD058): 표 전후 공백 줄을 추가하세요. Line 10의 표는 앞/뒤에 빈 줄이 필요합니다. 렌더링 일관성과 lint 통과를 위해 blank line을 넣어 주세요. 🧰 Tools🪛 markdownlint-cli2 (0.22.0)[warning] 10-10: Tables should be surrounded by blank lines (MD058, blanks-around-tables) 🤖 Prompt for AI Agents |
||
|
|
||
| --- | ||
| ## 🛠️ 팀원별 환경 설정 가이드 (로컬 개발용) | ||
|
|
||
| > **공통 외부 IP**: `34.64.218.236` | ||
| > 모든 팀원은 로컬에서 테스트할 때 아래 설정값을 참조하여 접속 정보를 수정해 주세요. | ||
| > | ||
| > > 🚨 **중요: 보안을 위해 DB 비밀번호가 코드에서 제거되었습니다.** | ||
| > 프로젝트를 처음 클론받거나 Pull 한 후, 반드시 프로젝트 최상단(루트) 경로에 **`.env`** 파일을 생성해 주세요. | ||
|
|
||
| ### 1️⃣ `.env` 파일 생성 (필수) | ||
| 프로젝트 루트에 `.env` 파일을 만들고 아래 내용을 입력합니다. (비밀번호는 카톡방 공지 확인) | ||
| ```text | ||
| MYSQL_ROOT_PASSWORD=여기에_공유된_비밀번호 | ||
|
|
||
| ``` | ||
|
|
||
| ### **.🍃 Spring Boot | ||
| `src/main/resources/application-be1.yml` 아래와 같이 수정합니다. | ||
|
Comment on lines
+34
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 헤더 강조 마크다운 문법이 깨져 렌더링이 불안정합니다.
수정 예시-### **.🍃 Spring Boot
+### 🍃 Spring Boot
-### **⚡FastAPI
+### ⚡ FastAPI
-### **📦 인프라 및 배포 설정 파일 안내(Dockerfile)
+### 📦 인프라 및 배포 설정 파일 안내 (Dockerfile)Also applies to: 103-104, 121-121, 125-125, 145-145 🤖 Prompt for AI Agents |
||
| ```yaml | ||
|
|
||
| server: | ||
| port: 8081 | ||
|
|
||
| spring: | ||
| datasource: | ||
| url: jdbc:mysql://veriq-db:3306/veriq_db?serverTimezone=Asia/Seoul&characterEncoding=UTF-8 | ||
| username: root | ||
| password: ${MYSQL_ROOT_PASSWORD} | ||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||
| # DB 연결을 최대 30초까지 기다려주는 인내심 설정 | ||
| hikari: | ||
| connection-timeout: 30000 | ||
|
|
||
| jpa: | ||
| hibernate: | ||
| ddl-auto: update | ||
| show-sql: true | ||
| properties: | ||
| hibernate: | ||
| format_sql: true | ||
| # MySQL 8.0 버전에 맞게 Dialect를 조금 더 구체적으로 지정 | ||
| dialect: org.hibernate.dialect.MySQL8Dialect | ||
|
|
||
| data: | ||
| redis: | ||
| host: veriq-redis | ||
| port: 6379 | ||
|
|
||
|
|
||
| be3: | ||
| api: | ||
| url: "http://localhost:8083/api/v1/scan/upload" | ||
| ``` | ||
| `src/main/resources/application-be3.yml` 아래와 같이 수정합니다. | ||
| ```yaml | ||
| server: | ||
| port: 8083 | ||
|
|
||
| spring: | ||
| datasource: | ||
| url: jdbc:mysql://veriq-db:3306/veriq_db?serverTimezone=Asia/Seoul&characterEncoding=UTF-8 | ||
| username: root | ||
| password: ${MYSQL_ROOT_PASSWORD} | ||
| driver-class-name: com.mysql.cj.jdbc.Driver | ||
| # DB 연결을 최대 30초까지 기다려주는 인내심 설정 | ||
| hikari: | ||
| connection-timeout: 30000 | ||
|
|
||
| jpa: | ||
| hibernate: | ||
| ddl-auto: update | ||
| show-sql: true | ||
| properties: | ||
| hibernate: | ||
| format_sql: true | ||
| # MySQL 8.0 버전에 맞게 Dialect를 조금 더 구체적으로 지정 | ||
| dialect: org.hibernate.dialect.MySQL8Dialect | ||
|
|
||
| data: | ||
| redis: | ||
| host: veriq-redis | ||
| port: 6379 | ||
|
|
||
| ``` | ||
|
|
||
| ### **⚡FastAPI | ||
| --env파일을 다음과 같이 수정합니다 | ||
| ```yaml | ||
| # Database 연결 정보 | ||
| DB_URL = "mysql+pymysql://root:[비밀번호]@34.64.218.236:3306/veriq_db" | ||
|
|
||
| # Redis 연결 정보 | ||
| REDIS_HOST = "34.64.218.236" | ||
| REDIS_PORT = 6379 | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| ### **📦 인프라 및 배포 설정 파일 안내(Dockerfile) | ||
|
|
||
|
|
||
|
|
||
| ### **🍃 Spring Boot Dockerfile | ||
|
|
||
| ```yaml | ||
| FROM eclipse-temurin:21-jdk | ||
|
|
||
| # 애플리케이션 전용 비루트 사용자 생성 | ||
| RUN groupadd -r appgroup && useradd -r -g appgroup appuser | ||
| WORKDIR /app | ||
|
|
||
| # JAR 파일 복사 및 권한 부여 | ||
| ARG JAR_FILE=build/libs/*.jar | ||
| COPY --chown=appuser:appgroup ${JAR_FILE} /app/app.jar | ||
|
|
||
| # 사용자 전환 및 실행 | ||
| USER appuser | ||
| ENTRYPOINT ["java", "-jar", "/app/app.jar"] | ||
| ``` | ||
|
|
||
|
|
||
|
|
||
| ### **⚡FastAPI Dockerfile | ||
| ```yaml | ||
| FROM python:3.9-slim | ||
| WORKDIR /app | ||
| COPY requirements.txt . | ||
| RUN pip install --no-cache-dir -r requirements.txt | ||
| COPY . . | ||
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] | ||
|
|
||
| ``` | ||
| ### **🐳 docker-compose.yml(공통) (최상위 경로) | ||
| ```yaml | ||
| services: | ||
| # 1. MySQL 데이터베이스 | ||
| veriq-db: | ||
| image: mysql:8.0 | ||
| container_name: veriq-db | ||
| restart: always | ||
| ports: | ||
| - "127.0.0.1:3306:3306" # 외부 IP 접속 차단, 로컬 호스트만 허용 | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | ||
| MYSQL_DATABASE: veriq_db | ||
| volumes: | ||
| - ./mysql_data:/var/lib/mysql | ||
|
|
||
| # 2. Redis 캐시 서버 | ||
| veriq-redis: | ||
| image: redis:latest | ||
| container_name: veriq-redis | ||
| restart: always | ||
| ports: | ||
| - "127.0.0.1:6379:6379" | ||
|
|
||
| # 3. Spring BE1 (Gateway) | ||
| veriq-gateway: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| container_name: veriq-be1 | ||
| restart: always | ||
| ports: | ||
| - "8081:8081" | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: be1 | ||
| BE3_API_URL: "http://veriq-platform:8083/api/v1/scan/upload" # 도커 내부망 주소로 덮어쓰기 | ||
| depends_on: | ||
| - veriq-db | ||
| - veriq-redis | ||
|
|
||
| # 4. Spring BE3 (Platform/Data Hub) | ||
| veriq-platform: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
| container_name: veriq-be3 | ||
| restart: always | ||
| ports: | ||
| - "8083:8083" | ||
| environment: | ||
| SPRING_PROFILES_ACTIVE: be3 | ||
| depends_on: | ||
| - veriq-db | ||
| - veriq-redis | ||
|
|
||
| # 5. FastAPI (분석 엔진) | ||
| veriq-analysis: | ||
| build: | ||
| context: ../analysis-engine | ||
| dockerfile: Dockerfile | ||
| container_name: veriq-analysis | ||
| restart: always | ||
| ports: | ||
| - "8000:8000" | ||
| depends_on: | ||
| - veriq-db | ||
|
|
||
| ``` | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| ### **GitHub Actions 자동 배포(🍃 Spring Boot) (.github/workflows/deploy.yml) | ||
| develop 브랜치에 코드가 푸시되면 자동으로 GCP 서버에 배포됩니다. | ||
|
|
||
| ```yaml | ||
| name: Veri-Q Develop Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "develop" ] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| packages: write | ||
| steps: | ||
| - name: SSH Remote Commands | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.GCP_IP }} | ||
| username: ${{ secrets.GCP_USER }} | ||
| key: ${{ secrets.GCP_SSH_KEY }} | ||
| script: | | ||
| cd /home/sk38808738/main-server | ||
| git pull origin develop | ||
| chmod +x gradlew | ||
| sudo ./gradlew bootJar | ||
|
|
||
| # GitHub Secrets에서 안전하게 비밀번호를 가져와 서버에 .env 파일 즉석 생성 | ||
| echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" > .env | ||
|
|
||
| # 컨테이너 빌드 및 재실행 | ||
| sudo docker-compose up --build -d | ||
| ``` | ||
| ### **GitHub Actions 자동 배포(⚡FastAPI) (.github/workflows/deploy.yml) | ||
| develop 브랜치에 코드가 푸시되면 자동으로 GCP 서버에 배포됩니다. | ||
|
|
||
| ```yaml | ||
| name: FastAPI Auto Deploy | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ "develop" ] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: SSH Remote Commands for FastAPI | ||
| uses: appleboy/ssh-action@master | ||
| with: | ||
| host: ${{ secrets.GCP_IP }} | ||
| username: ${{ secrets.GCP_USER }} | ||
| key: ${{ secrets.GCP_SSH_KEY }} | ||
| script: | | ||
| # 1. FastAPI 폴더로 이동해서 최신 코드 pull | ||
| cd /home/sk38808738/analysis-engine | ||
| git pull origin develop | ||
| # 2. 도커 설계도가 있는 메인 서버 폴더로 이동 | ||
| cd /home/sk38808738/main-server | ||
| sudo docker-compose up --build -d veriq-analysis | ||
|
|
||
|
|
||
|
|
||
| ``` | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
What is the latest stable version of appleboy/ssh-action GitHub Action?💡 Result:
The latest stable version of appleboy/ssh-action is v1.2.5, released on 2026-01-28.
Citations:
보안: GitHub Action 버전을 고정하세요.
appleboy/ssh-action@master대신 특정 버전 태그를 사용하세요.@master는 예고 없이 변경될 수 있어 보안 위험이 있습니다.🔒 버전 고정 제안
🤖 Prompt for AI Agents