diff --git a/.github/workflows/backend-prod.yml b/.github/workflows/backend-prod.yml index c19fc373..3ae0d1dc 100644 --- a/.github/workflows/backend-prod.yml +++ b/.github/workflows/backend-prod.yml @@ -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 @@ -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; @@ -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; @@ -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 \