Skip to content

Commit

Permalink
feat: blue green 무중단 배포 스크립트
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachneee committed Oct 15, 2024
1 parent b1effee commit 799734b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/backend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
echo "Checking if Nginx container exists..."
if sudo docker ps -a --filter "name=$NGINX_CONTAINER_NAME" --format "{{.Names}}" | grep -w $NGINX_CONTAINER_NAME; then
# 컨테이너가 실행 중인지 확인
# Check if the Nginx container is running
if sudo docker ps --filter "name=$NGINX_CONTAINER_NAME" --format "{{.Names}}" | grep -w $NGINX_CONTAINER_NAME; then
echo "Nginx container is running."
else
Expand All @@ -132,11 +132,11 @@ jobs:
echo "Nginx container started."
fi
# 호스트의 nginx.conf 파일을 수정
# Update Nginx configuration file on host
echo "Updating Nginx configuration file on host..."
sudo sed -i "s/proxy_pass http:\/\/127.0.0.1:.*;/proxy_pass http:\/\/127.0.0.1:${{ steps.check-port.outputs.next_port }};/" ./nginx.conf
# 컨테이너 내부에서 Nginx를 재로드
# Reload Nginx inside the container
echo "Reloading Nginx inside the container..."
sudo docker exec $NGINX_CONTAINER_NAME nginx -s reload
Expand All @@ -145,17 +145,25 @@ jobs:
else
echo "Nginx container not found. Creating a new Nginx container..."
# nginx.conf 파일 생성
# Create a basic Nginx config file with the updated proxy_pass
echo "
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:${{ steps.check-port.outputs.next_port }};
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:${{ steps.check-port.outputs.next_port }};
}
}
}
" > ./nginx.conf
# 새로운 Nginx 컨테이너 실행
# Run a new Nginx container with the updated config
sudo docker run -d --name $NGINX_CONTAINER_NAME -p 80:80 \
-v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro nginx
Expand Down

0 comments on commit 799734b

Please sign in to comment.