Skip to content

Commit

Permalink
ci: deploy.sh 의 docker 명령어에 sudo 권한 부여
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingyum-Kim committed Aug 5, 2023
1 parent d7d8351 commit 500df00
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ EXIST_BLUE=$(sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.bl

if [ -z "$EXIST_BLUE" ]; then
echo "> blue up"
docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml up -d --build
sudo docker-compose -p ${DOCKER_APP_NAME}-blue -f docker-compose.blue.yml up -d --build
BEFORE_COMPOSE_COLOR="green"
AFTER_COMPOSE_COLOR="blue"
else
echo "> green up"
docdker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml up -d --build
sudo docker-compose -p ${DOCKER_APP_NAME}-green -f docker-compose.green.yml up -d --build
BEFORE_COMPOSE_COLOR="blue"
AFTER_COMPOSE_COLOR="green"
fi

sleep 10

EXIST_AFTER=$(docker-compose -p ${DOCKER_APP_NAME}-${AFTER_COMPOSE_COLOR} -f docker-compose.${AFTER_COMPOSE_COLOR}.yml ps | grep UP)
EXIST_AFTER=$(sudo docker-compose -p ${DOCKER_APP_NAME}-${AFTER_COMPOSE_COLOR} -f docker-compose.${AFTER_COMPOSE_COLOR}.yml ps | grep UP)

if[ -n "$EXIST_AFTER"]; then
echo "> nginx reload .. "
NGINX_CONT=$(docker ps -q --filter ancestor=nginx)
docker exec -it "$NGINX_CONT" bash -c "cp /etc/nginx/nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf;nginx -s reload"
sudo docker exec -it "$NGINX_CONT" bash -c "cp /etc/nginx/nginx.${AFTER_COMPOSE_COLOR}.conf /etc/nginx/nginx.conf;nginx -s reload"

docker-compose -f docker-compose.${BEFORE_COMPOSE_COLOR}.yml down
docker rm $(docker ps -q -a -f "name=${BEFORE_COMPOSE_COLOR}")
sudo docker-compose -p ${DOCKER_APP_NAME}-${BEFORE_COMPOSE_COLOR} -f docker-compose.${BEFORE_COMPOSE_COLOR}.yml down
sudo docker rm $(docker ps -q -a -f "name=${BEFORE_COMPOSE_COLOR}")
echo "$BEFORE_COMPOSE_COLOR down"
fi

Expand Down

0 comments on commit 500df00

Please sign in to comment.