From 464580d64127ea89bfe676ef720540ba8891e0cc Mon Sep 17 00:00:00 2001 From: Sejeong Kim Date: Thu, 31 Oct 2024 00:12:25 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20docker-compse=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layer-api/infra/production/deploy.sh | 6 +-- ...-compose.yaml => docker-compose-blue.yaml} | 19 +------- .../production/docker-compose-green.yaml | 47 +++++++++++++++++++ 3 files changed, 52 insertions(+), 20 deletions(-) rename layer-api/infra/production/{docker-compose.yaml => docker-compose-blue.yaml} (68%) create mode 100644 layer-api/infra/production/docker-compose-green.yaml diff --git a/layer-api/infra/production/deploy.sh b/layer-api/infra/production/deploy.sh index 9410c67..8d4f18e 100644 --- a/layer-api/infra/production/deploy.sh +++ b/layer-api/infra/production/deploy.sh @@ -10,7 +10,7 @@ if [ -z $IS_GREEN ];then # blue라면 echo "1. get green image" echo "2. green container up" - sudo docker-compose up -d green # green 컨테이너 실행 + sudo docker-compose -f docker-compose-green.yaml up -d while [ 1 = 1 ]; do echo "3. green health check..." @@ -28,14 +28,14 @@ if [ -z $IS_GREEN ];then # blue라면 sudo nginx -s rel echo "5. blue container down" - sudo docker-compose stop blue + sudo docker-compose down blue else echo "1. get green image" cd ./layer-api/infra/production echo "2. blue container up" - sudo sdocker-compose up -d blue # green 컨테이너 실행 + sudo docker-compose -f docker-compose-blue.yaml up -d while [ 1 = 1 ]; do diff --git a/layer-api/infra/production/docker-compose.yaml b/layer-api/infra/production/docker-compose-blue.yaml similarity index 68% rename from layer-api/infra/production/docker-compose.yaml rename to layer-api/infra/production/docker-compose-blue.yaml index e223e92..c44239a 100644 --- a/layer-api/infra/production/docker-compose.yaml +++ b/layer-api/infra/production/docker-compose-blue.yaml @@ -1,7 +1,7 @@ services: blue: image: docker.io/clean01/layer-server_layer-api:latest - container_name: layer-api + container_name: blue ports: - "8080:8080" environment: @@ -14,24 +14,9 @@ services: networks: - app-network - green: - image: docker.io/clean01/layer-server_layer-api:latest - container_name: layer-api - ports: - - "8081:8080" - environment: - - TZ=Asia/Seoul - - SPRING_PROFILES_ACTIVE=prod - volumes: - - ./application-secret.properties:/config/application-secret.properties - - ./log:/log - - ./tokens:/config/tokens - networks: - - app-network - batch-job: image: docker.io/clean01/layer-server_layer-batch:latest - container_name: layer-batch + container_name: layer-batch_blue environment: - TZ=Asia/Seoul volumes: diff --git a/layer-api/infra/production/docker-compose-green.yaml b/layer-api/infra/production/docker-compose-green.yaml new file mode 100644 index 0000000..c44239a --- /dev/null +++ b/layer-api/infra/production/docker-compose-green.yaml @@ -0,0 +1,47 @@ +services: + blue: + image: docker.io/clean01/layer-server_layer-api:latest + container_name: blue + ports: + - "8080:8080" + environment: + - TZ=Asia/Seoul + - SPRING_PROFILES_ACTIVE=prod + volumes: + - ./application-secret.properties:/config/application-secret.properties + - ./log:/log + - ./tokens:/config/tokens + networks: + - app-network + + batch-job: + image: docker.io/clean01/layer-server_layer-batch:latest + container_name: layer-batch_blue + environment: + - TZ=Asia/Seoul + volumes: + - ./application-secret.properties:/config/application-secret.properties + - ./log:/log + - ./tokens:/config/tokens + networks: + - app-network + depends_on: + - blue + - green + restart: always + + nginx: + image: nginx:latest + container_name: nginx + depends_on: + - blue + - green + ports: + - "80:80" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + networks: + - app-network + +networks: + app-network: \ No newline at end of file