Skip to content

Commit c70ddf8

Browse files
committed
feat: 무중단 배포(blue-green) 스크립트 및 CI/CD 파이프라인 적용
- backend, frontend blue-green 배포 스크립트 추가 및 헬스 체크 구현 - nginx 설정을 blue-green 환경에 맞게 수정 - GitHub Actions 워크플로우에서 무중단 배포 자동화 적용 - 프론트엔드 헬스 체크 추가 및 백엔드 actuator 활용
1 parent 6ba4f84 commit c70ddf8

File tree

5 files changed

+56
-21
lines changed

5 files changed

+56
-21
lines changed

.github/workflows/ci-cd.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@ jobs:
7373
host: ${{ secrets.EC2_HOST }}
7474
username: ubuntu
7575
key: ${{ secrets.EC2_PRIVATE_KEY }}
76+
# 배포 무중단 (blue-green 스위칭 전략)
7677
script: |
77-
cd ~/NBE5-7-2-TEAM08
78-
docker-compose pull
79-
docker-compose down
80-
docker-compose up -d --build
78+
cd ~/NBE5-7-2-TEAM08/deployment
79+
chmod +x ./deploy.sh
80+
./deploy.sh
81+
# 중단방식
82+
# script: |
83+
# cd ~/NBE5-7-2-TEAM08
84+
# docker-compose pull
85+
# docker-compose down
86+
# docker-compose up -d --build

backend/build.gradle

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ dependencies {
4545
implementation 'io.awspring.cloud:spring-cloud-aws-starter:3.1.1'
4646
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.767'
4747

48+
implementation 'org.springframework.boot:spring-boot-starter-actuator'
49+
4850
compileOnly 'org.projectlombok:lombok'
4951
runtimeOnly 'com.mysql:mysql-connector-j'
5052
annotationProcessor 'org.projectlombok:lombok'
53+
5154
testImplementation 'org.springframework.boot:spring-boot-starter-test'
5255
testImplementation 'org.springframework.security:spring-security-test'
5356
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
54-
55-
compileOnly 'org.projectlombok:lombok'
56-
annotationProcessor 'org.projectlombok:lombok'
57-
runtimeOnly 'com.mysql:mysql-connector-j'
58-
5957
testCompileOnly 'org.projectlombok:lombok'
6058
testAnnotationProcessor 'org.projectlombok:lombok'
6159
}

backend/src/main/resources/application-prod.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@ jwt:
8585
logging:
8686
level:
8787
org.springframework.security: DEBUG
88+
89+
management:
90+
endpoints:
91+
web:
92+
exposure:
93+
include: health,info,metrics,env
94+
endpoint:
95+
health:
96+
show-details: always

docker-compose.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
services:
22

3-
dev-chat-backend:
3+
dev-chat-backend-blue:
44
image: limkanghyun/dev-chat-backend
5-
container_name: dev-chat-backend
5+
container_name: dev-chat-backend-blue
66
ports:
7-
- "8080:8080"
7+
- "8081:8080" # 내부는 8080이지만 외부는 8082
88
env_file:
99
- ./backend/.env
1010
environment:
@@ -14,29 +14,51 @@ services:
1414
networks:
1515
- dev-chat-network
1616

17-
dev-chat-frontend:
17+
dev-chat-backend-green:
18+
image: limkanghyun/dev-chat-backend
19+
container_name: dev-chat-backend-green
20+
ports:
21+
- "8082:8080" # 내부는 8080이지만 외부는 8082
22+
env_file:
23+
- ./backend/.env
24+
environment:
25+
- TZ=Asia/Seoul
26+
depends_on:
27+
- prometheus
28+
networks:
29+
- dev-chat-network
30+
31+
dev-chat-frontend-blue:
1832
image: limkanghyun/dev-chat-frontend
19-
container_name: dev-chat-frontend
33+
container_name: dev-chat-frontend-blue
2034
ports:
2135
- "3000:80"
22-
depends_on:
23-
- dev-chat-backend
36+
networks:
37+
- dev-chat-network
38+
39+
dev-chat-frontend-green:
40+
image: limkanghyun/dev-chat-frontend:green
41+
container_name: dev-chat-frontend-green
42+
ports:
43+
- "3001:80"
2444
networks:
2545
- dev-chat-network
2646

2747
nginx_proxy:
2848
image: nginx:latest
2949
container_name: nginx_proxy
3050
volumes:
31-
- ./nginx.conf:/etc/nginx/nginx.conf:ro
51+
- ./nginx.conf:/etc/nginx/nginx.conf
3252
- /etc/letsencrypt/archive/thedevchat.duckdns.org/fullchain1.pem:/etc/letsencrypt/live/thedevchat.duckdns.org/fullchain.pem:ro
3353
- /etc/letsencrypt/archive/thedevchat.duckdns.org/privkey1.pem:/etc/letsencrypt/live/thedevchat.duckdns.org/privkey.pem:ro
3454
ports:
3555
- "80:80"
3656
- "443:443"
3757
depends_on:
38-
- dev-chat-frontend
39-
- dev-chat-backend
58+
- dev-chat-frontend-blue
59+
- dev-chat-frontend-green
60+
- dev-chat-backend-blue
61+
- dev-chat-backend-green
4062
networks:
4163
- dev-chat-network
4264

nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ events { }
22

33
http {
44
upstream frontend {
5-
server dev-chat-frontend:80; # React 컨테이너
5+
server dev-chat-frontend-blue:80; # React 컨테이너
66
}
77

88
upstream backend {
9-
server dev-chat-backend:8080; # Spring Boot 컨테이너
9+
server dev-chat-backend-blue:8080; # Spring Boot 컨테이너
1010
}
1111

1212
server {

0 commit comments

Comments
 (0)