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

[ALL] chore: 그린,블루별 서비스 이름 변경 #578

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 1 addition & 5 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 Down Expand Up @@ -58,7 +54,7 @@ fi
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