-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from boostcampwm-2024/dev-back
[BE] main으로 머지
- Loading branch information
Showing
137 changed files
with
35,577 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- be-feat#46 | ||
|
||
jobs: | ||
# 먼저 레포지토리 체크아웃 | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
permissions: | ||
packages: read | ||
|
||
# 콘솔 서버 배포 | ||
deploy-console-server: | ||
needs: setup | ||
uses: ./.github/workflows/deploy-service.yml | ||
with: | ||
service: web35-watchducks | ||
path: backend/console-server | ||
source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" | ||
secrets: | ||
user: ${{ secrets.SSH_USER }} | ||
port: ${{ secrets.SSH_PORT }} | ||
key: ${{ secrets.SSH_KEY }} | ||
host: ${{ secrets.CONSOLE_SERVER_HOST }} | ||
env: ${{ secrets.CONSOLE_SERVER_ENV }} | ||
tok: ${{secrets.GHCR_TOKEN}} | ||
|
||
# 프록시 서버 배포 | ||
deploy-proxy-server: | ||
needs: setup | ||
uses: ./.github/workflows/deploy-service.yml | ||
with: | ||
service: web35-watchducks | ||
path: backend/proxy-server | ||
source: "./web35-watchducks/backend/proxy-server/*.yml" | ||
use_host_nginx: true | ||
secrets: | ||
user: ${{ secrets.SSH_USER }} | ||
port: ${{ secrets.SSH_PORT }} | ||
key: ${{ secrets.SSH_KEY }} | ||
host: ${{ secrets.PROXY_SERVER_HOST }} | ||
env: ${{ secrets.PROXY_SERVER_ENV }} | ||
tok: ${{secrets.GHCR_TOKEN}} | ||
|
||
|
||
# 네임서버 배포 | ||
deploy-name-server: | ||
needs: setup | ||
uses: ./.github/workflows/deploy-service.yml | ||
with: | ||
service: web35-watchducks | ||
path: backend/name-server | ||
source: "./web35-watchducks/backend/name-server/*.yml, ./web35-watchducks/backend/name-server/*.conf" | ||
secrets: | ||
user: ${{ secrets.SSH_USER }} | ||
port: ${{ secrets.SSH_PORT }} | ||
key: ${{ secrets.SSH_KEY }} | ||
host: ${{ secrets.NAME_SERVER_HOST }} | ||
env: ${{ secrets.NAME_SERVER_ENV }} | ||
tok: ${{secrets.GHCR_TOKEN}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
name: Deploy Service | ||
|
||
permissions: | ||
contents: read | ||
|
||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
service: | ||
required: true | ||
type: string | ||
path: | ||
required: true | ||
type: string | ||
source: | ||
type: string | ||
use_host_nginx: | ||
required: false | ||
type: boolean | ||
default: false | ||
secrets: | ||
host: | ||
required: true | ||
user: | ||
required: true | ||
key: | ||
required: true | ||
port: | ||
required: true | ||
env: | ||
required: true | ||
tok: | ||
required: true | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
# Sparse checkout으로 하위 디렉토리만 체크아웃 | ||
- name: Checkout repository with sparse checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
path: ${{ inputs.service }} | ||
fetch-depth: 0 | ||
sparse-checkout: | | ||
${{ inputs.path }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Transfer YAML files using SCP | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.host }} | ||
username: ${{ secrets.user }} | ||
key: ${{ secrets.key }} | ||
port: ${{ secrets.port }} | ||
source: ${{ inputs.source }} | ||
target: "/home/watchducks/app" | ||
strip_components: 3 | ||
|
||
# GHCR 로그인 | ||
- name: Log in to GHCR | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.tok }} | ||
|
||
# 도커 이미지 빌드 & 푸시 | ||
- name: Build and push Docker image for ${{ inputs.service }} | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: ./${{ inputs.service }}/${{ inputs.path }} | ||
file: ./${{ inputs.service }}/${{ inputs.path }}/Dockerfile | ||
tags: | | ||
ghcr.io/${{ github.repository_owner }}/${{ inputs.service }}/${{ inputs.path }}:${{ github.sha }} | ||
ghcr.io/${{ github.repository_owner }}/${{ inputs.service }}/${{ inputs.path }}:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
|
||
# 각 서비스 서버에 배포 | ||
- name: Deploy ${{ inputs.service }} to server | ||
uses: appleboy/ssh-action@v1.1.0 | ||
with: | ||
host: ${{ secrets.host }} | ||
username: ${{ secrets.user }} | ||
key: ${{ secrets.key }} | ||
port: ${{ secrets.port }} | ||
script: | | ||
cd /home/watchducks/app | ||
touch .env | ||
echo "${{ secrets.env }}" > .env | ||
echo "${{ secrets.tok }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | ||
# 최신 이미지 가져오기 | ||
docker-compose pull | ||
# 호스트에 설치된 Nginx를 사용할지 확인 | ||
if [ "${{ inputs.use_host_nginx }}" == "true" ]; then | ||
# Dockerized Nginx 없이 Blue 컨테이너만 시작 | ||
docker-compose up -d --no-deps server-blue | ||
# Blue 인스턴스 헬스 체크 - 최대 5번 시도 | ||
echo "Blue 컨테이너 헬스 상태 확인 중..." | ||
for i in {1..5}; do | ||
health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') | ||
if [ "$health_status" == "healthy" ]; then | ||
echo "Blue 컨테이너가 정상 상태입니다." | ||
break | ||
else | ||
echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다. 시도 $i/5..." | ||
sleep 10 | ||
fi | ||
done | ||
# 최종 헬스 상태 확인 | ||
if [ "$health_status" != "healthy" ]; then | ||
echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." | ||
exit 1 | ||
fi | ||
# Nginx 재로드 | ||
sudo nginx -s reload | ||
echo "호스트 Nginx 리로드 완료로 트래픽 전환 완료" | ||
else | ||
# 콘솔 서버의 Dockerized Nginx 설정 | ||
docker-compose up -d --no-deps nginx | ||
# Dockerized Nginx와 함께 Blue 컨테이너 시작 | ||
docker-compose up -d --no-deps server-blue | ||
# Blue 인스턴스 헬스 체크 - 최대 5번 시도 | ||
echo "Blue 컨테이너 헬스 상태 확인 중..." | ||
for i in {1..5}; do | ||
health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') | ||
if [ "$health_status" == "healthy" ]; then | ||
echo "Blue 컨테이너가 정상 상태입니다." | ||
break | ||
else | ||
echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다. 시도 $i/5..." | ||
sleep 10 | ||
fi | ||
done | ||
# 최종 헬스 상태 확인 | ||
if [ "$health_status" != "healthy" ]; then | ||
echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." | ||
exit 1 | ||
fi | ||
# Dockerized Nginx 리로드로 트래픽 전환 | ||
docker-compose exec nginx nginx -s reload | ||
echo "Dockerized Nginx 리로드 완료로 트래픽 전환 완료" | ||
fi | ||
# Green 컨테이너 시작 (두 설정 모두에서 수행) | ||
docker-compose up -d --no-deps server-green | ||
echo "배포가 성공적으로 완료되었습니다." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
### WebStorm ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
.idea/ | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# AWS User-specific | ||
.idea/**/aws.xml | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/artifacts | ||
# .idea/compiler.xml | ||
# .idea/jarRepositories.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project.query.ts format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# SonarLint plugin | ||
.idea/sonarlint/ | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### WebStorm Patch ### | ||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 | ||
|
||
# *.iml | ||
# modules.xml | ||
# .idea/misc.xml | ||
# *.ipr | ||
|
||
# Sonarlint plugin | ||
# https://plugins.jetbrains.com/plugin/7973-sonarlint | ||
.idea/**/sonarlint/ | ||
|
||
# SonarQube Plugin | ||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin | ||
.idea/**/sonarIssues.xml | ||
|
||
# Markdown Navigator plugin | ||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced | ||
.idea/**/markdown-navigator.xml | ||
.idea/**/markdown-navigator-enh.xml | ||
.idea/**/markdown-navigator/ | ||
|
||
# Cache file creation bug | ||
# See https://youtrack.jetbrains.com/issue/JBR-2257 | ||
.idea/$CACHE_FILE$ | ||
|
||
# CodeStream plugin | ||
# https://plugins.jetbrains.com/plugin/12206-codestream | ||
.idea/codestream.xml | ||
|
||
# Azure Toolkit for IntelliJ plugin | ||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij | ||
.idea/**/azureSettings.xml | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/node,webstorm | ||
|
||
### macOS ### | ||
# General | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
|
||
# Icon must end with two \r | ||
Icon | ||
|
||
|
||
# Thumbnails | ||
._* | ||
|
||
# Files that might appear in the root of a volume | ||
.DocumentRevisions-V100 | ||
.fseventsd | ||
.Spotlight-V100 | ||
.TemporaryItems | ||
.Trashes | ||
.VolumeIcon.icns | ||
.com.apple.timemachine.donotpresent | ||
|
||
# Directories potentially created on remote AFP share | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk | ||
|
||
### macOS Patch ### | ||
# iCloud generated files | ||
*.icloud |
Oops, something went wrong.