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 9b1d1c1 commit 5f35ea9
Showing 1 changed file with 11 additions and 38 deletions.
49 changes: 11 additions & 38 deletions .github/workflows/backend-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,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
# Nginx 컨테이너가 실행 중인지 확인
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 @@ -145,10 +145,10 @@ jobs:
echo "Nginx container started."
fi
# Ensure nginx-conf directory and default.conf file exist
# nginx-conf 디렉토리 생성
mkdir -p ./nginx-conf
# Create or update the default.conf file with the new configuration
# default.conf 파일 생성 또는 업데이트
echo "Creating or updating default.conf..."
echo "server {
listen 80;
Expand All @@ -162,32 +162,19 @@ jobs:
}
}" > ./nginx-conf/default.conf
# Test Nginx configuration inside a temporary container
echo "Testing Nginx configuration..."
sudo docker run --rm \
-v $(pwd)/nginx-conf:/etc/nginx/conf.d:ro \
--network $NETWORK_NAME \
nginx nginx -t
if [ $? -eq 0 ]; then
echo "Nginx configuration test passed."
else
echo "Nginx configuration test failed. Please check the configuration file."
exit 1
fi
# Restart the Nginx container to apply changes
echo "Restarting Nginx container..."
sudo docker restart $NGINX_CONTAINER_NAME
echo "Nginx container restarted."
# Nginx 컨테이너 내부에서 설정 리로드
echo "Reloading Nginx configuration..."
sudo docker cp ./nginx-conf/default.conf $NGINX_CONTAINER_NAME:/etc/nginx/conf.d/default.conf
sudo docker exec $NGINX_CONTAINER_NAME nginx -s reload
echo "Nginx configuration reloaded."
else
echo "Nginx container not found. Creating a new Nginx container..."
# Create nginx-conf directory
# nginx-conf 디렉토리 생성
mkdir -p ./nginx-conf
# Create the default.conf file with the initial configuration
# default.conf 파일 생성
echo "Creating default.conf..."
echo "server {
listen 80;
Expand All @@ -201,21 +188,7 @@ jobs:
}
}" > ./nginx-conf/default.conf
# Test Nginx configuration inside a temporary container
echo "Testing Nginx configuration..."
sudo docker run --rm \
-v $(pwd)/nginx-conf:/etc/nginx/conf.d:ro \
--network $NETWORK_NAME \
nginx nginx -t
if [ $? -eq 0 ]; then
echo "Nginx configuration test passed."
else
echo "Nginx configuration test failed. Please check the configuration file."
exit 1
fi
# Run a new Nginx container with the updated config
# 새로운 Nginx 컨테이너 실행
sudo docker run -d \
--name $NGINX_CONTAINER_NAME \
--network $NETWORK_NAME \
Expand Down

0 comments on commit 5f35ea9

Please sign in to comment.