Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
[ALL] chore: 그린,블루별 서비스 이름 변경 (#578)
Browse files Browse the repository at this point in the history
* chore: 그린,블루별 서비스 이름 변경

* chore: 불필요한 변수 제거
  • Loading branch information
Eun-chan Cho committed Oct 19, 2023
1 parent f003dd2 commit de4d33d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
8 changes: 2 additions & 6 deletions compose-blue.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
version: "3"
services:
frontend:
frontend-blue:
image: ${DOCKER_USERNAME}/dong-gle-frontend-${INFRA_PROFILE}
ports:
- 3000:3000

backend:
backend-blue:
image: ${DOCKER_USERNAME}/dong-gle-backend-${INFRA_PROFILE}
ports:
- 8080:8080
volumes:
- /home/ubuntu/logs/:/logs/
environment:
Expand Down
8 changes: 2 additions & 6 deletions compose-green.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
version: "3"
services:
frontend:
frontend-green:
image: ${DOCKER_USERNAME}/dong-gle-frontend-${INFRA_PROFILE}
ports:
- 3001:3000

backend:
backend-green:
image: ${DOCKER_USERNAME}/dong-gle-backend-${INFRA_PROFILE}
ports:
- 8081:8080
volumes:
- /home/ubuntu/logs/:/logs/
environment:
Expand Down
6 changes: 3 additions & 3 deletions conf-dev/nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ server{

location /api {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://backend:${BACKEND_PORT};
proxy_pass http://backend-${AFTER_COMPOSE_COLOR}:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
proxy_pass http://frontend:${FRONTEND_PORT};
proxy_pass http://frontend-${AFTER_COMPOSE_COLOR}:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /v3 {
proxy_pass http://backend:${BACKEND_PORT};
proxy_pass http://backend-${AFTER_COMPOSE_COLOR}:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
6 changes: 3 additions & 3 deletions conf-prod/nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ server{

location /api {
rewrite ^/api/(.*) /$1 break;
proxy_pass http://backend:${BACKEND_PORT};
proxy_pass http://backend-${AFTER_COMPOSE_COLOR}:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
proxy_pass http://frontend:${FRONTEND_PORT};
proxy_pass http://frontend-${AFTER_COMPOSE_COLOR}:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /v3 {
proxy_pass http://backend:${BACKEND_PORT};
proxy_pass http://backend-${AFTER_COMPOSE_COLOR}:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
10 changes: 4 additions & 6 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ if [ -z "$EXIST_BLUE" ]; then
sudo docker compose -p compose-blue -f compose-blue.yml up -d
BEFORE_COMPOSE_COLOR="green"
AFTER_COMPOSE_COLOR="blue"
export BACKEND_PORT=8080
export FRONTEND_PORT=3000
else
echo "green up"
sudo docker compose -p compose-green -f compose-green.yml pull
sudo docker compose -p compose-green -f compose-green.yml up -d
BEFORE_COMPOSE_COLOR="blue"
AFTER_COMPOSE_COLOR="green"
export BACKEND_PORT=8081
export FRONTEND_PORT=3001
fi

sleep 10
Expand All @@ -53,12 +49,14 @@ else
exit 1
fi
fi


export AFTER_COMPOSE_COLOR

# 새로운 컨테이너가 제대로 떴는지 확인
EXIST_AFTER=$(sudo docker compose -p compose-${AFTER_COMPOSE_COLOR} -f compose-${AFTER_COMPOSE_COLOR}.yml ps | grep Up)
if [ -n "$EXIST_AFTER" ]; then
# nginx.config를 컨테이너에 맞게 변경해주고 reload 한다
envsubst '${FRONTEND_PORT},${BACKEND_PORT}' < conf-${INFRA_PROFILE}/nginx.template > conf-${INFRA_PROFILE}/nginx.conf
envsubst '${AFTER_COMPOSE_COLOR}' < conf-${INFRA_PROFILE}/nginx.template > conf-${INFRA_PROFILE}/nginx.conf
sudo docker compose -f compose-nginx.yml exec nginx nginx -s reload

# 이전 컨테이너 종료
Expand Down

0 comments on commit de4d33d

Please sign in to comment.