From 5027481aafd39c3f95605747eef48fdd46ae5d9f Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 14:27:05 +0900 Subject: [PATCH 01/47] =?UTF-8?q?feat:=20blue,=20green=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EB=8B=A4=EB=A5=B8=20=ED=8F=AC=ED=8A=B8=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 4 ++-- backend/console-server/nginx.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 905b129f..6e49c78f 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -14,7 +14,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3000 + - PORT=3001 restart: always volumes: - ./.env:/usr/src/app/.env @@ -23,7 +23,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3000 + - PORT=3002 restart: always volumes: - ./.env:/usr/src/app/.env \ No newline at end of file diff --git a/backend/console-server/nginx.conf b/backend/console-server/nginx.conf index 6bc47ca0..9c43fd50 100644 --- a/backend/console-server/nginx.conf +++ b/backend/console-server/nginx.conf @@ -1,7 +1,7 @@ http { upstream console_server { - server server-blue:3000 weight=1; - server server-green:3000 backup; + server server-blue:3001 weight=1; + server server-green:3002 backup; } server { From 44f26f65dabe5f2f80792d25fabb448e3d348525 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 14:30:07 +0900 Subject: [PATCH 02/47] =?UTF-8?q?chore:=20=EC=84=A4=EC=A0=95=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20input.source=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EB=84=98=EA=B2=A8=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 1 + .github/workflows/deploy-service.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index dd0eaeab..b192b4cb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -38,6 +38,7 @@ jobs: with: service: web35-watchducks path: backend/console-server + source: "./${{ inputs.service }}/${{ inputs.path }}/*.yml, ./${{ inputs.service }}/${{ inputs.path }}/*.conf" secrets: host: ${{ secrets.CONSOLE_SERVER_HOST }} user: ${{ secrets.SSH_USER }} diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index f8baf6a3..7be2ffcb 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -53,7 +53,7 @@ jobs: username: ${{ secrets.user }} key: ${{ secrets.key }} port: ${{ secrets.port }} - source: "./${{ inputs.service }}/${{ inputs.path }}/*.yml, ./${{ inputs.service }}/${{ inputs.path }}/*.conf" + source: ${{ inputs.source }} target: "/home/watchducks/app" strip_components: 3 From d574b4f2699c9e89f0def30d7a94a178dba8a2fe Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 14:31:04 +0900 Subject: [PATCH 03/47] =?UTF-8?q?chore:=20=EC=84=A4=EC=A0=95=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20input.source=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EB=84=98=EA=B2=A8=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 7be2ffcb..602113a2 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -9,6 +9,8 @@ on: path: required: true type: string + source: + type: string secrets: host: required: true From c0199c5f6966bc79359f0eba216f0017e3545f9e Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 14:35:27 +0900 Subject: [PATCH 04/47] =?UTF-8?q?chore:=20=EC=84=A4=EC=A0=95=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20input.source=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EB=84=98=EA=B2=A8=EC=A3=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b192b4cb..b4e8bd95 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -38,7 +38,7 @@ jobs: with: service: web35-watchducks path: backend/console-server - source: "./${{ inputs.service }}/${{ inputs.path }}/*.yml, ./${{ inputs.service }}/${{ inputs.path }}/*.conf" + source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" secrets: host: ${{ secrets.CONSOLE_SERVER_HOST }} user: ${{ secrets.SSH_USER }} From 5d4a96d241e2ce7b5052760c8658528210276f5a Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 15:37:36 +0900 Subject: [PATCH 05/47] fix: typeorm synchronize false --- backend/console-server/src/config/typeorm.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/console-server/src/config/typeorm.config.ts b/backend/console-server/src/config/typeorm.config.ts index 18248a23..ddb2e3ba 100644 --- a/backend/console-server/src/config/typeorm.config.ts +++ b/backend/console-server/src/config/typeorm.config.ts @@ -22,7 +22,7 @@ export default registerAs('typeOrmConfig', () => { password: process.env.DB_PASSWORD, database: process.env.DB_NAME, autoLoadEntities: true, - synchronize: true, + synchronize: false, } ) as TypeOrmModuleOptions; }); From 2cbb53d96453faaca2a097e378c1179d7e8bdcd7 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 15:42:18 +0900 Subject: [PATCH 06/47] =?UTF-8?q?chore:=20=ED=8F=AC=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 4 ++-- backend/console-server/nginx.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 6e49c78f..905b129f 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -14,7 +14,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3001 + - PORT=3000 restart: always volumes: - ./.env:/usr/src/app/.env @@ -23,7 +23,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3002 + - PORT=3000 restart: always volumes: - ./.env:/usr/src/app/.env \ No newline at end of file diff --git a/backend/console-server/nginx.conf b/backend/console-server/nginx.conf index 9c43fd50..6bc47ca0 100644 --- a/backend/console-server/nginx.conf +++ b/backend/console-server/nginx.conf @@ -1,7 +1,7 @@ http { upstream console_server { - server server-blue:3001 weight=1; - server server-green:3002 backup; + server server-blue:3000 weight=1; + server server-green:3000 backup; } server { From 09e4763bcba8e89038cd1bbf983fc2dde0daeaa4 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 16:04:16 +0900 Subject: [PATCH 07/47] =?UTF-8?q?fix:=20=EC=BA=90=EC=8B=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 602113a2..d45478c8 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -1,5 +1,9 @@ name: Deploy Service +permissions: + contents: read + packages: write + on: workflow_call: inputs: @@ -37,17 +41,6 @@ jobs: sparse-checkout: | ${{ inputs.path }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Cache Docker images - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: docker-compose-cache-${{ github.sha }} - restore-keys: | - docker-compose-cache- - - name: Transfer YAML files using SCP uses: appleboy/scp-action@master with: From fb5b177fd28a3c2b53840ac98a1496ac334088db Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 16:05:15 +0900 Subject: [PATCH 08/47] =?UTF-8?q?fix:=20=EC=BA=90=EC=8B=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index d45478c8..9bcd0e41 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -41,6 +41,9 @@ jobs: sparse-checkout: | ${{ inputs.path }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Transfer YAML files using SCP uses: appleboy/scp-action@master with: From 5b31adba53af6e623457a94371326d0d58308642 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 16:08:11 +0900 Subject: [PATCH 09/47] =?UTF-8?q?fix:=20=EB=B9=8C=EB=93=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 9bcd0e41..0f30e7c7 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -74,6 +74,7 @@ jobs: ghcr.io/${{ github.repository_owner }}/${{ inputs.service }}/${{ inputs.path }}:latest cache-from: type=gha cache-to: type=gha,mode=max + push: true # 각 서비스 서버에 배포 - name: Deploy ${{ inputs.service }} to server From 5d115ca064c7ad49deeebb7f3977e65cebf21665 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 16:15:30 +0900 Subject: [PATCH 10/47] =?UTF-8?q?fix:=20=ED=8F=AC=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 4 ++-- backend/console-server/nginx.conf | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 905b129f..6e49c78f 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -14,7 +14,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3000 + - PORT=3001 restart: always volumes: - ./.env:/usr/src/app/.env @@ -23,7 +23,7 @@ services: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest environment: - NODE_ENV=production - - PORT=3000 + - PORT=3002 restart: always volumes: - ./.env:/usr/src/app/.env \ No newline at end of file diff --git a/backend/console-server/nginx.conf b/backend/console-server/nginx.conf index 6bc47ca0..9c43fd50 100644 --- a/backend/console-server/nginx.conf +++ b/backend/console-server/nginx.conf @@ -1,7 +1,7 @@ http { upstream console_server { - server server-blue:3000 weight=1; - server server-green:3000 backup; + server server-blue:3001 weight=1; + server server-green:3002 backup; } server { From 708057e87c4d874c646a7a38664df24bee9edc18 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 17:07:04 +0900 Subject: [PATCH 11/47] =?UTF-8?q?feat:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=97=AC=EC=8A=A4=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=EC=98=B5=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 30 ++++++++++++----------- .github/workflows/deploy-service.yml | 10 ++------ backend/console-server/docker-compose.yml | 12 ++++++++- backend/proxy-server/docker-compose.yml | 19 ++++++++++++++ 4 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 backend/proxy-server/docker-compose.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b4e8bd95..2be2c134 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -40,23 +40,25 @@ jobs: path: backend/console-server source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" secrets: - host: ${{ secrets.CONSOLE_SERVER_HOST }} user: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_KEY }} port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.CONSOLE_SERVER_HOST }} env: ${{ secrets.CONSOLE_SERVER_ENV }} -# # 프록시 서버 배포 -# deploy-proxy-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: proxy-server -# path: backend/proxy-server -# key_secret: SSH_KEY -# port_secret: SSH_PORT -# host_secret: PROXY_SERVER_HOST -# user_secret: PROXY_SERVER_USER -# env_secret: PROXY_SERVER_ENV + # 프록시 서버 배포 + deploy-proxy-server: + needs: setup + uses: ./.github/workflows/deploy-service.yml + with: + service: proxy-server + path: backend/proxy-server + source: "./web35-watchducks/backend/proxy-server/*.yml" + secrets: + user: ${{ secrets.SSH_USER }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.PROXY_SERVER_HOST }} + env: ${{ secrets.PROXY_SERVER_ENV }} diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 0f30e7c7..c9c6c406 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -108,14 +108,8 @@ jobs: docker-compose up -d --no-deps server-blue # Blue 인스턴스 헬스 체크 - for i in {1..30}; do - if curl -s http://localhost/api | grep -q "Hello World!"; then - echo "Blue container is ready" - break - fi - echo "Waiting for Blue container to be ready..." - sleep 1 - done + echo "Waiting for Blue container to be healthy..." + docker-compose ps | grep console-server-blue | grep "healthy" || (echo "Blue container did not become healthy" && exit 1) # Nginx 리로드로 트래픽 전환 docker-compose exec nginx nginx -s reload diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 6e49c78f..1a5688c1 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -18,6 +18,11 @@ services: restart: always volumes: - ./.env:/usr/src/app/.env + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:3001/"] + interval: 10s + timeout: 2s + retries: 3 server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest @@ -26,4 +31,9 @@ services: - PORT=3002 restart: always volumes: - - ./.env:/usr/src/app/.env \ No newline at end of file + - ./.env:/usr/src/app/.env + healthcheck: + test: [ "CMD", "curl", "-f", "http://localhost:3002/" ] + interval: 10s + timeout: 2s + retries: 3 \ No newline at end of file diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml new file mode 100644 index 00000000..b5832ba6 --- /dev/null +++ b/backend/proxy-server/docker-compose.yml @@ -0,0 +1,19 @@ +version: '3' +services: + server-blue: + image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest + environment: + - NODE_ENV=production + - PORT=3001 + restart: always + volumes: + - ./.env:/usr/src/app/.env + + server-green: + image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest + environment: + - NODE_ENV=production + - PORT=3001 + restart: always + volumes: + - ./.env:/usr/src/app/.env \ No newline at end of file From 88dee34ea23db9a138feeabc29105ad37fa8f688 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 17:08:18 +0900 Subject: [PATCH 12/47] =?UTF-8?q?feat:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=97=AC=EC=8A=A4=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=EC=98=B5=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index c9c6c406..c23a05db 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -109,7 +109,7 @@ jobs: # Blue 인스턴스 헬스 체크 echo "Waiting for Blue container to be healthy..." - docker-compose ps | grep console-server-blue | grep "healthy" || (echo "Blue container did not become healthy" && exit 1) + docker-compose ps | grep server-blue | grep "healthy" || (echo "Blue container did not become healthy" && exit 1) # Nginx 리로드로 트래픽 전환 docker-compose exec nginx nginx -s reload From 1daf5779929aaffece22b613319569b4d28d2620 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 17:08:50 +0900 Subject: [PATCH 13/47] =?UTF-8?q?feat:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=97=AC=EC=8A=A4=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=EC=98=B5=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2be2c134..c96cd5d7 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -47,18 +47,18 @@ jobs: env: ${{ secrets.CONSOLE_SERVER_ENV }} - # 프록시 서버 배포 - deploy-proxy-server: - needs: setup - uses: ./.github/workflows/deploy-service.yml - with: - service: proxy-server - path: backend/proxy-server - source: "./web35-watchducks/backend/proxy-server/*.yml" - secrets: - user: ${{ secrets.SSH_USER }} - port: ${{ secrets.SSH_PORT }} - key: ${{ secrets.SSH_KEY }} - host: ${{ secrets.PROXY_SERVER_HOST }} - env: ${{ secrets.PROXY_SERVER_ENV }} +# # 프록시 서버 배포 +# deploy-proxy-server: +# needs: setup +# uses: ./.github/workflows/deploy-service.yml +# with: +# service: proxy-server +# path: backend/proxy-server +# source: "./web35-watchducks/backend/proxy-server/*.yml" +# secrets: +# user: ${{ secrets.SSH_USER }} +# port: ${{ secrets.SSH_PORT }} +# key: ${{ secrets.SSH_KEY }} +# host: ${{ secrets.PROXY_SERVER_HOST }} +# env: ${{ secrets.PROXY_SERVER_ENV }} From 208f5f02e7b80d100ecbb133e4c1eaa92bbdfd85 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 17:51:44 +0900 Subject: [PATCH 14/47] =?UTF-8?q?feat:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=97=AC=EC=8A=A4=EC=B2=B4=ED=81=AC=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 10 ++++++++-- backend/console-server/docker-compose.yml | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index c23a05db..928a192e 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -108,8 +108,14 @@ jobs: docker-compose up -d --no-deps server-blue # Blue 인스턴스 헬스 체크 - echo "Waiting for Blue container to be healthy..." - docker-compose ps | grep server-blue | grep "healthy" || (echo "Blue container did not become healthy" && exit 1) + echo "Checking Blue container health status..." + health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + if [ "$health_status" == "healthy" ]; then + echo "Blue container is healthy" + else + echo "Blue container did not become healthy" + exit 1 + fi # Nginx 리로드로 트래픽 전환 docker-compose exec nginx nginx -s reload diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 1a5688c1..58a857d7 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -19,7 +19,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:3001/"] + test: ["CMD", "nc", "-z", "localhost", "3001"] interval: 10s timeout: 2s retries: 3 @@ -33,7 +33,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: [ "CMD", "curl", "-f", "http://localhost:3002/" ] + test: ["CMD", "nc", "-z", "localhost", "3002"] interval: 10s timeout: 2s retries: 3 \ No newline at end of file From 3594b8690ed21392b85bd1a57d10fb0ed369732a Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 17:53:56 +0900 Subject: [PATCH 15/47] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 928a192e..0e44f7a3 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -109,7 +109,7 @@ jobs: # Blue 인스턴스 헬스 체크 echo "Checking Blue container health status..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') if [ "$health_status" == "healthy" ]; then echo "Blue container is healthy" else From bb99b9b4dbbe1c9888edeaa1a652477febd813c9 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 18:05:16 +0900 Subject: [PATCH 16/47] =?UTF-8?q?fix:=20nginx=20=ED=97=AC=EC=8A=A4?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=20=EC=A0=9C=EA=B1=B0=20-=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EC=9D=B8=EC=8A=A4=ED=84=B4=EC=8A=A4=20=EB=A1=9C?= =?UTF-8?q?=EC=BB=AC=EC=97=90=20=EC=9E=88=EB=8A=94=20nginx=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=EC=9E=88?= =?UTF-8?q?=EC=9D=8C=20-=20=EC=83=81=EC=9A=A9=20=EC=84=9C=EB=B9=84?= =?UTF-8?q?=EC=8A=A4=EC=9D=B4=EB=8B=88=20=EC=83=81=EB=8C=80=EC=A0=81?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=95=88=EC=A0=95=EC=A0=81,=20=EB=82=98?= =?UTF-8?q?=EC=A4=91=EC=97=90=20=EA=B3=A0=EB=A0=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 0e44f7a3..beae604b 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -93,16 +93,6 @@ jobs: docker-compose pull # Nginx 시작 (재시작 포함) docker-compose up -d --no-deps nginx - - # Nginx가 실행 중인지 확인 - for i in {1..10}; do - if docker-compose ps | grep nginx | grep "Up"; then - echo "Nginx is running" - break - fi - echo "Waiting for Nginx to be ready..." - sleep 2 - done # Blue 인스턴스를 새 버전으로 준비 docker-compose up -d --no-deps server-blue From 4d48436b2fb010a1f03e2dd8aa0b50c6a1e795a7 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:06:38 +0900 Subject: [PATCH 17/47] =?UTF-8?q?feat:=20=EB=B9=8C=EB=93=9C=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=9E=91=EC=84=B1=20-=20tsc-alia?= =?UTF-8?q?s=EB=A1=9C=20import=EC=8B=9C=20.js=20=EB=B6=99=EC=9E=84=20-=20n?= =?UTF-8?q?ode=20dist/app.js=20=EC=8B=A4=ED=96=89=20=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/proxy-server/package-lock.json | 197 +++++++++++++++++++++++++ backend/proxy-server/package.json | 3 + backend/proxy-server/tsconfig.json | 23 ++- 3 files changed, 217 insertions(+), 6 deletions(-) diff --git a/backend/proxy-server/package-lock.json b/backend/proxy-server/package-lock.json index da45f4ae..123ed4c2 100644 --- a/backend/proxy-server/package-lock.json +++ b/backend/proxy-server/package-lock.json @@ -31,6 +31,7 @@ "jest": "^29.7.0", "prettier": "^3.3.3", "ts-jest": "^29.2.5", + "tsc-alias": "^1.8.10", "tsx": "^4.19.2", "typescript": "^5.6.3" } @@ -3559,6 +3560,16 @@ "dev": true, "license": "Python-2.0" }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -3800,6 +3811,19 @@ "tweetnacl": "^0.14.3" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3961,6 +3985,44 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -4065,6 +4127,16 @@ "node": ">= 0.8" } }, + "node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4245,6 +4317,19 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -5231,6 +5316,27 @@ "node": ">=4" } }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -5459,6 +5565,19 @@ "dev": true, "license": "MIT" }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-core-module": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", @@ -6637,6 +6756,20 @@ "dev": true, "license": "MIT" }, + "node_modules/mylas": { + "version": "2.1.13", + "resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz", + "integrity": "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/raouldeheer" + } + }, "node_modules/mysql2": { "version": "3.11.4", "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.11.4.tgz", @@ -6907,6 +7040,16 @@ "dev": true, "license": "MIT" }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -6993,6 +7136,19 @@ "node": ">=8" } }, + "node_modules/plimit-lit": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.6.1.tgz", + "integrity": "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "queue-lit": "^1.5.1" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -7146,6 +7302,16 @@ "node": ">=0.4.x" } }, + "node_modules/queue-lit": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.2.tgz", + "integrity": "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -7180,6 +7346,19 @@ "dev": true, "license": "MIT" }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/real-require": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/real-require/-/real-require-0.2.0.tgz", @@ -7919,6 +8098,24 @@ } } }, + "node_modules/tsc-alias": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.10.tgz", + "integrity": "sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.3", + "commander": "^9.0.0", + "globby": "^11.0.4", + "mylas": "^2.1.9", + "normalize-path": "^3.0.0", + "plimit-lit": "^1.2.6" + }, + "bin": { + "tsc-alias": "dist/bin/index.js" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", diff --git a/backend/proxy-server/package.json b/backend/proxy-server/package.json index 8b975101..97ed4d1d 100644 --- a/backend/proxy-server/package.json +++ b/backend/proxy-server/package.json @@ -3,8 +3,10 @@ "version": "1.0.0", "description": "", "main": "src/app.ts", + "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", + "build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json", "dev": "tsx src/app.ts" }, "repository": { @@ -28,6 +30,7 @@ "jest": "^29.7.0", "prettier": "^3.3.3", "ts-jest": "^29.2.5", + "tsc-alias": "^1.8.10", "tsx": "^4.19.2", "typescript": "^5.6.3" }, diff --git a/backend/proxy-server/tsconfig.json b/backend/proxy-server/tsconfig.json index 670150d5..8d185800 100644 --- a/backend/proxy-server/tsconfig.json +++ b/backend/proxy-server/tsconfig.json @@ -3,13 +3,24 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "node", + "outDir": "dist", + "rootDir": "src", "esModuleInterop": true, "strict": true, - "outDir": "dist", - "rootDir": "./", - "types": ["jest"], // Jest 타입 정의 추가 - "allowSyntheticDefaultImports": true // Babel 사용 시 필요 + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "declaration": true, + "typeRoots": ["./node_modules/@types"], + "baseUrl": "./", + "paths": { + "*": ["src/*"] + } }, - "include": ["src/**/*", "test/**/*"], // 테스트 디렉토리 포함 - "exclude": ["node_modules"] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test"], + "tsc-alias": { + "resolveFullPaths": true, + "resolveFullExtension": ".js" + } } \ No newline at end of file From 59a677766062f01bf7e77c540e58f8b1b4d93ab1 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:07:43 +0900 Subject: [PATCH 18/47] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9D=EC=8B=9C=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20CI/CD=20yml=20=EB=93=B1=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 29 +++++++------ .github/workflows/deploy-service.yml | 58 +++++++++++++++++-------- backend/proxy-server/Dockerfile | 20 +++++++++ backend/proxy-server/docker-compose.yml | 6 ++- 4 files changed, 80 insertions(+), 33 deletions(-) create mode 100644 backend/proxy-server/Dockerfile diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index c96cd5d7..268aa59d 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -47,18 +47,19 @@ jobs: env: ${{ secrets.CONSOLE_SERVER_ENV }} -# # 프록시 서버 배포 -# deploy-proxy-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: proxy-server -# path: backend/proxy-server -# source: "./web35-watchducks/backend/proxy-server/*.yml" -# secrets: -# user: ${{ secrets.SSH_USER }} -# port: ${{ secrets.SSH_PORT }} -# key: ${{ secrets.SSH_KEY }} -# host: ${{ secrets.PROXY_SERVER_HOST }} -# env: ${{ secrets.PROXY_SERVER_ENV }} + # 프록시 서버 배포 + deploy-proxy-server: + needs: setup + uses: ./.github/workflows/deploy-service.yml + with: + service: proxy-server + path: backend/proxy-server + source: "./web35-watchducks/backend/proxy-server/*.yml" + use_host_nginx: true + secrets: + user: ${{ secrets.SSH_USER }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.PROXY_SERVER_HOST }} + env: ${{ secrets.PROXY_SERVER_ENV }} diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index beae604b..e87e9184 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -15,6 +15,10 @@ on: type: string source: type: string + use_host_nginx: + required: false + type: boolean + default: false secrets: host: required: true @@ -91,25 +95,45 @@ jobs: # 최신 이미지 가져오기 docker-compose pull - # Nginx 시작 (재시작 포함) - docker-compose up -d --no-deps nginx - - # Blue 인스턴스를 새 버전으로 준비 - docker-compose up -d --no-deps server-blue - # Blue 인스턴스 헬스 체크 - echo "Checking Blue container health status..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') - if [ "$health_status" == "healthy" ]; then - echo "Blue container is healthy" + # 호스트에 설치된 Nginx를 사용할지 확인 + if [ "${{ inputs.use_host_nginx }}" == "true" ]; then + # Dockerized Nginx 없이 Blue 컨테이너만 시작 + docker-compose up -d --no-deps server-blue + + # Blue 인스턴스 헬스 체크 + echo "Blue 컨테이너 헬스 상태 확인 중..." + health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + if [ "$health_status" == "healthy" ]; then + echo "Blue 컨테이너가 정상 상태입니다." + else + echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." + exit 1 + fi + sudo nginx -s reload + echo "호스트 Nginx 리로드 완료로 트래픽 전환 완료" + else - echo "Blue container did not become healthy" - exit 1 - fi + # 콘솔 서버의 Dockerized Nginx 설정 + docker-compose up -d --no-deps nginx - # Nginx 리로드로 트래픽 전환 - docker-compose exec nginx nginx -s reload + # Dockerized Nginx와 함께 Blue 컨테이너 시작 + docker-compose up -d --no-deps server-blue + + # Blue 인스턴스 헬스 체크 + echo "Blue 컨테이너 헬스 상태 확인 중..." + health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + if [ "$health_status" == "healthy" ]; then + echo "Blue 컨테이너가 정상 상태입니다." + else + echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." + exit 1 + fi + + # Dockerized Nginx 리로드로 트래픽 전환 + docker-compose exec nginx nginx -s reload + fi - # 기존 Green 인스턴스 종료 + # Green 컨테이너 시작 (두 설정 모두에서 수행) docker-compose up -d --no-deps server-green - echo "Deployment completed successfully" \ No newline at end of file + echo "배포가 성공적으로 완료되었습니다." \ No newline at end of file diff --git a/backend/proxy-server/Dockerfile b/backend/proxy-server/Dockerfile new file mode 100644 index 00000000..ae3665aa --- /dev/null +++ b/backend/proxy-server/Dockerfile @@ -0,0 +1,20 @@ +# 베이스 이미지 설정 +FROM node:22-alpine + +# 작업 디렉토리 설정 +WORKDIR /usr/src/app + +# package.json 및 package-lock.json 복사 +COPY package*.json ./ + +# 의존성 설치 +RUN npm install + +# 소스 코드 복사 +COPY . . + +# TypeScript 빌드 +RUN npm run build + +# 앱 실행 +CMD ["node", "dist/app.js"] \ No newline at end of file diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml index b5832ba6..a9ccdee2 100644 --- a/backend/proxy-server/docker-compose.yml +++ b/backend/proxy-server/docker-compose.yml @@ -8,12 +8,14 @@ services: restart: always volumes: - ./.env:/usr/src/app/.env + network_mode: "host" server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest environment: - NODE_ENV=production - - PORT=3001 + - PORT=3002 restart: always volumes: - - ./.env:/usr/src/app/.env \ No newline at end of file + - ./.env:/usr/src/app/.env + network_mode: "host" \ No newline at end of file From 3bc65beb294a8e76d6c149089a449614fa3d1f16 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:12:47 +0900 Subject: [PATCH 19/47] =?UTF-8?q?fix:=20=EC=84=A4=EC=A0=95=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EC=88=98=EC=A0=95=20-=20docker-compose=EA=B0=80=20?= =?UTF-8?q?=EC=95=84=EB=8B=8C=20docker=20=EC=93=B8=20=EB=95=8C=20=EC=BB=A8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20-=20=ED=94=84=EB=A1=9D=EC=8B=9C=EC=84=9C=EB=B2=84?= =?UTF-8?q?=20service=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/deploy-service.yml | 4 ++-- backend/proxy-server/ecosystem.config.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 backend/proxy-server/ecosystem.config.js diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 268aa59d..bdda112e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -52,7 +52,7 @@ jobs: needs: setup uses: ./.github/workflows/deploy-service.yml with: - service: proxy-server + service: web35-watchducks path: backend/proxy-server source: "./web35-watchducks/backend/proxy-server/*.yml" use_host_nginx: true diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index e87e9184..7fc122a3 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -103,7 +103,7 @@ jobs: # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') if [ "$health_status" == "healthy" ]; then echo "Blue 컨테이너가 정상 상태입니다." else @@ -122,7 +122,7 @@ jobs: # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' server-blue | tr -d '"') + health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') if [ "$health_status" == "healthy" ]; then echo "Blue 컨테이너가 정상 상태입니다." else diff --git a/backend/proxy-server/ecosystem.config.js b/backend/proxy-server/ecosystem.config.js new file mode 100644 index 00000000..b922f08d --- /dev/null +++ b/backend/proxy-server/ecosystem.config.js @@ -0,0 +1,10 @@ +module.exports = { + apps: [ + { + name: 'proxy-server', + script: 'dist/src/app.js', // 빌드된 애플리케이션 진입점 + instances: 'max', // CPU 코어 수에 따라 인스턴스 수 자동 조절 + exec_mode: 'cluster', + }, + ], +}; From 8575e3b14efd950b2e9896424b5296748e469410 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:30:34 +0900 Subject: [PATCH 20/47] =?UTF-8?q?fix:=20PAT=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/deploy-service.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index bdda112e..c131e58f 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -7,7 +7,7 @@ on: - be-feat#46 jobs: - # 먼저 sparse checkout으로 레포지토리 체크아웃 + # 먼저 레포지토리 체크아웃 setup: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 7fc122a3..ebdbd67b 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -65,7 +65,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GHCR_TOKEN }} # 도커 이미지 빌드 & 푸시 - name: Build and push Docker image for ${{ inputs.service }} From 507335f0da38d7e58ed1c2efcbb97b58590d5869 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:36:07 +0900 Subject: [PATCH 21/47] =?UTF-8?q?fix:=20=ED=86=A0=ED=81=B0=20=EB=84=98?= =?UTF-8?q?=EA=B2=A8=EC=A3=BC=EB=8A=94=20=EB=B0=A9=EC=8B=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 3 ++- .github/workflows/deploy-service.yml | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index c131e58f..9093193a 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -45,6 +45,7 @@ jobs: key: ${{ secrets.SSH_KEY }} host: ${{ secrets.CONSOLE_SERVER_HOST }} env: ${{ secrets.CONSOLE_SERVER_ENV }} + tok: ${{secrets.GHCR_TOKEN}} # 프록시 서버 배포 @@ -62,4 +63,4 @@ jobs: key: ${{ secrets.SSH_KEY }} host: ${{ secrets.PROXY_SERVER_HOST }} env: ${{ secrets.PROXY_SERVER_ENV }} - + tok: ${{secrets.GHCR_TOKEN}} diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index ebdbd67b..5775dddd 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -30,6 +30,8 @@ on: required: true env: required: true + tok: + required: true jobs: deploy: @@ -65,7 +67,7 @@ jobs: with: registry: ghcr.io username: ${{ github.actor }} - password: ${{ secrets.GHCR_TOKEN }} + password: ${{ secrets.tok }} # 도커 이미지 빌드 & 푸시 - name: Build and push Docker image for ${{ inputs.service }} From 4846a2227538bac46aa41ea80df5fa64a0c5b32d Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:41:05 +0900 Subject: [PATCH 22/47] =?UTF-8?q?chore:=20ghcr=20login=20action=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EB=86=92=EC=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 5775dddd..4758f3b2 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -63,7 +63,7 @@ jobs: # GHCR 로그인 - name: Log in to GHCR - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} From 8eeeadc21c7675bab4d66237a4c8914c033c254e Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:43:09 +0900 Subject: [PATCH 23/47] =?UTF-8?q?fix:=20=EA=B6=8C=ED=95=9C=20=EC=9C=84?= =?UTF-8?q?=EC=B9=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 4758f3b2..102aff37 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -2,7 +2,7 @@ name: Deploy Service permissions: contents: read - packages: write + on: workflow_call: @@ -36,7 +36,8 @@ on: jobs: deploy: runs-on: ubuntu-latest - + permissions: + packages: write steps: # Sparse checkout으로 하위 디렉토리만 체크아웃 - name: Checkout repository with sparse checkout From 8ce1fb8f38e8e14ca004585c00ead06e4922d658 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 21:59:27 +0900 Subject: [PATCH 24/47] =?UTF-8?q?fix:=20Dockerfile=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/proxy-server/Dockerfile | 15 ++++++++++++--- backend/proxy-server/ecosystem.config.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/backend/proxy-server/Dockerfile b/backend/proxy-server/Dockerfile index ae3665aa..f0974837 100644 --- a/backend/proxy-server/Dockerfile +++ b/backend/proxy-server/Dockerfile @@ -4,10 +4,13 @@ FROM node:22-alpine # 작업 디렉토리 설정 WORKDIR /usr/src/app +# NODE_ENV 설정 (프로덕션 모드) +ENV NODE_ENV=production + # package.json 및 package-lock.json 복사 COPY package*.json ./ -# 의존성 설치 +# 프로덕션 의존성 설치 RUN npm install # 소스 코드 복사 @@ -16,5 +19,11 @@ COPY . . # TypeScript 빌드 RUN npm run build -# 앱 실행 -CMD ["node", "dist/app.js"] \ No newline at end of file +# PM2 설치 +RUN npm install pm2 -g + +# PM2 설정 파일 복사 (옵션) +COPY ecosystem.config.js ./ + +# PM2로 앱 실행 +CMD ["pm2-runtime", "ecosystem.config.js"] \ No newline at end of file diff --git a/backend/proxy-server/ecosystem.config.js b/backend/proxy-server/ecosystem.config.js index b922f08d..49272120 100644 --- a/backend/proxy-server/ecosystem.config.js +++ b/backend/proxy-server/ecosystem.config.js @@ -2,7 +2,7 @@ module.exports = { apps: [ { name: 'proxy-server', - script: 'dist/src/app.js', // 빌드된 애플리케이션 진입점 + script: 'dist/app.js', // 빌드된 애플리케이션 진입점 instances: 'max', // CPU 코어 수에 따라 인스턴스 수 자동 조절 exec_mode: 'cluster', }, From 0a814ebd7fad99652fb2eb217525520dd2347fec Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:02:17 +0900 Subject: [PATCH 25/47] =?UTF-8?q?fix:=20Dockerfile=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 30 +++++++++++++++--------------- backend/proxy-server/Dockerfile | 32 ++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 9093193a..796f3187 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -18,19 +18,6 @@ jobs: permissions: packages: read -# # 네임서버 배포 -# deploy-name-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: name-server -# path: backend/name-server -# key_secret: SSH_KEY -# port_secret: SSH_PORT -# host_secret: NAME_SERVER_HOST -# user_secret: NAME_SERVER_USER -# env_secret: NAME_SERVER_ENV - # 콘솔 서버 배포 deploy-console-server: needs: setup @@ -47,10 +34,9 @@ jobs: env: ${{ secrets.CONSOLE_SERVER_ENV }} tok: ${{secrets.GHCR_TOKEN}} - # 프록시 서버 배포 deploy-proxy-server: - needs: setup + needs: deploy-console-server uses: ./.github/workflows/deploy-service.yml with: service: web35-watchducks @@ -64,3 +50,17 @@ jobs: host: ${{ secrets.PROXY_SERVER_HOST }} env: ${{ secrets.PROXY_SERVER_ENV }} tok: ${{secrets.GHCR_TOKEN}} + + +# # 네임서버 배포 +# deploy-name-server: +# needs: setup +# uses: ./.github/workflows/deploy-service.yml +# with: +# service: name-server +# path: backend/name-server +# key_secret: SSH_KEY +# port_secret: SSH_PORT +# host_secret: NAME_SERVER_HOST +# user_secret: NAME_SERVER_USER +# env_secret: NAME_SERVER_ENV \ No newline at end of file diff --git a/backend/proxy-server/Dockerfile b/backend/proxy-server/Dockerfile index f0974837..bd2e213a 100644 --- a/backend/proxy-server/Dockerfile +++ b/backend/proxy-server/Dockerfile @@ -1,29 +1,33 @@ -# 베이스 이미지 설정 -FROM node:22-alpine +# 빌드 스테이지 +FROM node:22-alpine AS build -# 작업 디렉토리 설정 WORKDIR /usr/src/app -# NODE_ENV 설정 (프로덕션 모드) -ENV NODE_ENV=production - -# package.json 및 package-lock.json 복사 +# 패키지 파일 복사 및 의존성 설치 COPY package*.json ./ - -# 프로덕션 의존성 설치 RUN npm install -# 소스 코드 복사 +# 소스 코드 복사 및 빌드 COPY . . - -# TypeScript 빌드 RUN npm run build -# PM2 설치 +# 런타임 스테이지 +FROM node:22-alpine + +WORKDIR /usr/src/app + +# 프로덕션 의존성 설치 +COPY package*.json ./ +RUN npm install --production + +# 빌드 결과물 복사 +COPY --from=build /usr/src/app/dist ./dist + +# PM2 설치 (옵션) RUN npm install pm2 -g # PM2 설정 파일 복사 (옵션) COPY ecosystem.config.js ./ -# PM2로 앱 실행 +# 애플리케이션 실행 CMD ["pm2-runtime", "ecosystem.config.js"] \ No newline at end of file From b8eeeb587dac7c57b2972d83867297d0fcf4f53d Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:19:39 +0900 Subject: [PATCH 26/47] =?UTF-8?q?chore:=20=ED=97=AC=EC=8A=A4=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=8B=9C=EA=B0=84=20=EC=97=B0=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 58a857d7..e1a71409 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -22,7 +22,7 @@ services: test: ["CMD", "nc", "-z", "localhost", "3001"] interval: 10s timeout: 2s - retries: 3 + retries: 5 server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest @@ -36,4 +36,4 @@ services: test: ["CMD", "nc", "-z", "localhost", "3002"] interval: 10s timeout: 2s - retries: 3 \ No newline at end of file + retries: 5 \ No newline at end of file From d114b6b67cc9026866d796ac14b6b97facc2cef9 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:26:43 +0900 Subject: [PATCH 27/47] =?UTF-8?q?chore:=20=EB=8F=84=EC=BB=A4=20=EC=BB=A8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=A7=80=EC=97=B0=20=EC=A3=BC?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 102aff37..82ecf3bb 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -103,6 +103,7 @@ jobs: if [ "${{ inputs.use_host_nginx }}" == "true" ]; then # Dockerized Nginx 없이 Blue 컨테이너만 시작 docker-compose up -d --no-deps server-blue + sleep 5 # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." @@ -123,6 +124,8 @@ jobs: # Dockerized Nginx와 함께 Blue 컨테이너 시작 docker-compose up -d --no-deps server-blue + sleep 5 + # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') From 4f0f7949f08861814f780a4464d908a8f23497d2 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:32:49 +0900 Subject: [PATCH 28/47] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/proxy-server/docker-compose.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml index a9ccdee2..e1188253 100644 --- a/backend/proxy-server/docker-compose.yml +++ b/backend/proxy-server/docker-compose.yml @@ -8,7 +8,6 @@ services: restart: always volumes: - ./.env:/usr/src/app/.env - network_mode: "host" server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest @@ -17,5 +16,4 @@ services: - PORT=3002 restart: always volumes: - - ./.env:/usr/src/app/.env - network_mode: "host" \ No newline at end of file + - ./.env:/usr/src/app/.env \ No newline at end of file From 1dce373cea6522abf1a79744892c0f5e87baf120 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:33:20 +0900 Subject: [PATCH 29/47] =?UTF-8?q?chore:=20=ED=94=84=EB=A1=9D=EC=8B=9C=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=EB=A7=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 796f3187..0aa2eddb 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -19,24 +19,24 @@ jobs: packages: read # 콘솔 서버 배포 - deploy-console-server: - needs: setup - uses: ./.github/workflows/deploy-service.yml - with: - service: web35-watchducks - path: backend/console-server - source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" - secrets: - user: ${{ secrets.SSH_USER }} - port: ${{ secrets.SSH_PORT }} - key: ${{ secrets.SSH_KEY }} - host: ${{ secrets.CONSOLE_SERVER_HOST }} - env: ${{ secrets.CONSOLE_SERVER_ENV }} - tok: ${{secrets.GHCR_TOKEN}} +# deploy-console-server: +# needs: setup +# uses: ./.github/workflows/deploy-service.yml +# with: +# service: web35-watchducks +# path: backend/console-server +# source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" +# secrets: +# user: ${{ secrets.SSH_USER }} +# port: ${{ secrets.SSH_PORT }} +# key: ${{ secrets.SSH_KEY }} +# host: ${{ secrets.CONSOLE_SERVER_HOST }} +# env: ${{ secrets.CONSOLE_SERVER_ENV }} +# tok: ${{secrets.GHCR_TOKEN}} # 프록시 서버 배포 deploy-proxy-server: - needs: deploy-console-server + needs: setup uses: ./.github/workflows/deploy-service.yml with: service: web35-watchducks From 0588584820e7e3965683aae3f8eb14269921c653 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:47:05 +0900 Subject: [PATCH 30/47] =?UTF-8?q?fix:=20=EC=B5=9C=EC=B4=88=20ghcr=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 2 ++ backend/proxy-server/docker-compose.yml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 82ecf3bb..e532ef07 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -96,6 +96,8 @@ jobs: touch .env echo "${{ secrets.env }}" > .env + echo "${{ secrets.tok }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + # 최신 이미지 가져오기 docker-compose pull diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml index e1188253..66c98406 100644 --- a/backend/proxy-server/docker-compose.yml +++ b/backend/proxy-server/docker-compose.yml @@ -8,6 +8,7 @@ services: restart: always volumes: - ./.env:/usr/src/app/.env + network_mode: "host" server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest @@ -16,4 +17,5 @@ services: - PORT=3002 restart: always volumes: - - ./.env:/usr/src/app/.env \ No newline at end of file + - ./.env:/usr/src/app/.env + network_mode: "host" From 26897d94791bec6f3a95af74d03e3f2767521abd Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:51:46 +0900 Subject: [PATCH 31/47] =?UTF-8?q?chore:=20=EC=BB=A8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=84=88=20=EC=9D=B4=EB=A6=84=20=EC=A7=81=EC=A0=91=20=EB=AA=85?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 2 ++ backend/proxy-server/docker-compose.yml | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index e1a71409..3222518d 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -12,6 +12,7 @@ services: server-blue: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest + container_name: app-server-blue-1 environment: - NODE_ENV=production - PORT=3001 @@ -26,6 +27,7 @@ services: server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/console-server:latest + container_name: app-server-green-1 environment: - NODE_ENV=production - PORT=3002 diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml index 66c98406..df5de039 100644 --- a/backend/proxy-server/docker-compose.yml +++ b/backend/proxy-server/docker-compose.yml @@ -2,6 +2,7 @@ version: '3' services: server-blue: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest + container_name: app-server-blue-1 environment: - NODE_ENV=production - PORT=3001 @@ -9,9 +10,15 @@ services: volumes: - ./.env:/usr/src/app/.env network_mode: "host" + healthcheck: + test: [ "CMD", "nc", "-z", "localhost", "3001" ] + interval: 10s + timeout: 2s + retries: 5 server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/proxy-server:latest + container_name: app-server-green-1 environment: - NODE_ENV=production - PORT=3002 @@ -19,3 +26,8 @@ services: volumes: - ./.env:/usr/src/app/.env network_mode: "host" + healthcheck: + test: [ "CMD", "nc", "-z", "localhost", "3001" ] + interval: 10s + timeout: 2s + retries: 5 \ No newline at end of file From 8cfc61d0b2cac0734002887f40100836bf224daa Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 22:58:52 +0900 Subject: [PATCH 32/47] =?UTF-8?q?fix:=20=EC=97=90=EC=BD=94=EC=8B=9C?= =?UTF-8?q?=EC=8A=A4=ED=85=9C=20cjs=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/proxy-server/Dockerfile | 4 ++-- .../{ecosystem.config.js => ecosystem.config.cjs} | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename backend/proxy-server/{ecosystem.config.js => ecosystem.config.cjs} (100%) diff --git a/backend/proxy-server/Dockerfile b/backend/proxy-server/Dockerfile index bd2e213a..80c315cf 100644 --- a/backend/proxy-server/Dockerfile +++ b/backend/proxy-server/Dockerfile @@ -27,7 +27,7 @@ COPY --from=build /usr/src/app/dist ./dist RUN npm install pm2 -g # PM2 설정 파일 복사 (옵션) -COPY ecosystem.config.js ./ +COPY ecosystem.config.cjs ./ # 애플리케이션 실행 -CMD ["pm2-runtime", "ecosystem.config.js"] \ No newline at end of file +CMD ["pm2-runtime", "ecosystem.config.cjs"] \ No newline at end of file diff --git a/backend/proxy-server/ecosystem.config.js b/backend/proxy-server/ecosystem.config.cjs similarity index 100% rename from backend/proxy-server/ecosystem.config.js rename to backend/proxy-server/ecosystem.config.cjs From f214453f8578df9648c60ec97cdece85319c75da Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:04:01 +0900 Subject: [PATCH 33/47] =?UTF-8?q?chore:=20=EB=8F=84=EC=BB=A4=20=EC=BB=A8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=84=88=20=EC=A7=80=EC=97=B0=20=EC=A3=BC?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index e532ef07..60392b61 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -105,7 +105,7 @@ jobs: if [ "${{ inputs.use_host_nginx }}" == "true" ]; then # Dockerized Nginx 없이 Blue 컨테이너만 시작 docker-compose up -d --no-deps server-blue - sleep 5 + sleep 10 # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." @@ -126,7 +126,7 @@ jobs: # Dockerized Nginx와 함께 Blue 컨테이너 시작 docker-compose up -d --no-deps server-blue - sleep 5 + sleep 10 # Blue 인스턴스 헬스 체크 echo "Blue 컨테이너 헬스 상태 확인 중..." From 0e34d1091285b785f8ea6eb0bfc0678c3f991e5f Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:17:59 +0900 Subject: [PATCH 34/47] =?UTF-8?q?feat:=20=EB=B9=8C=EB=93=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/package-lock.json | 197 ++++++++++++++++++++++++++ backend/name-server/package.json | 3 +- backend/name-server/tsconfig.json | 23 ++- 3 files changed, 216 insertions(+), 7 deletions(-) diff --git a/backend/name-server/package-lock.json b/backend/name-server/package-lock.json index 9017112f..a502bbfa 100644 --- a/backend/name-server/package-lock.json +++ b/backend/name-server/package-lock.json @@ -34,6 +34,7 @@ "jest": "^29.7.0", "prettier": "^3.3.3", "ts-jest": "^29.2.5", + "tsc-alias": "^1.8.10", "tsx": "^4.19.2", "typescript": "^5.6.3" } @@ -3516,6 +3517,16 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/asn1": { "version": "0.2.6", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.6.tgz", @@ -3765,6 +3776,19 @@ "prebuild-install": "^7.1.1" } }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/bindings": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", @@ -3968,6 +3992,44 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -4048,6 +4110,16 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/commander": { + "version": "9.5.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz", + "integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || >=14" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -4235,6 +4307,19 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/dns-packet": { "version": "5.6.1", "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", @@ -5024,6 +5109,27 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -5193,6 +5299,19 @@ "dev": true, "license": "MIT" }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-core-module": { "version": "2.15.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", @@ -6286,6 +6405,20 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/mylas": { + "version": "2.1.13", + "resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.13.tgz", + "integrity": "sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/raouldeheer" + } + }, "node_modules/mysql2": { "version": "3.11.4", "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.11.4.tgz", @@ -6543,6 +6676,16 @@ "dev": true, "license": "MIT" }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -6641,6 +6784,19 @@ "node": ">=8" } }, + "node_modules/plimit-lit": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.6.1.tgz", + "integrity": "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "queue-lit": "^1.5.1" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/prebuild-install": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", @@ -6781,6 +6937,16 @@ ], "license": "MIT" }, + "node_modules/queue-lit": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.2.tgz", + "integrity": "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -6846,6 +7012,19 @@ "node": ">= 6" } }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", @@ -7519,6 +7698,24 @@ } } }, + "node_modules/tsc-alias": { + "version": "1.8.10", + "resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.10.tgz", + "integrity": "sha512-Ibv4KAWfFkFdKJxnWfVtdOmB0Zi1RJVxcbPGiCDsFpCQSsmpWyuzHG3rQyI5YkobWwxFPEyQfu1hdo4qLG2zPw==", + "dev": true, + "license": "MIT", + "dependencies": { + "chokidar": "^3.5.3", + "commander": "^9.0.0", + "globby": "^11.0.4", + "mylas": "^2.1.9", + "normalize-path": "^3.0.0", + "plimit-lit": "^1.2.6" + }, + "bin": { + "tsc-alias": "dist/bin/index.js" + } + }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", diff --git a/backend/name-server/package.json b/backend/name-server/package.json index e7806543..f132214b 100644 --- a/backend/name-server/package.json +++ b/backend/name-server/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "tsx watch src/index.ts", "start": "tsx src/index.ts", - "build": "tsx build src/index.ts", + "build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json", "tmp": "tsx src/index.ts", "lint": "eslint src/**/*.ts", "lint:fix": "eslint src/**/*.ts --fix", @@ -38,6 +38,7 @@ "jest": "^29.7.0", "prettier": "^3.3.3", "ts-jest": "^29.2.5", + "tsc-alias": "^1.8.10", "tsx": "^4.19.2", "typescript": "^5.6.3" }, diff --git a/backend/name-server/tsconfig.json b/backend/name-server/tsconfig.json index 670150d5..8d185800 100644 --- a/backend/name-server/tsconfig.json +++ b/backend/name-server/tsconfig.json @@ -3,13 +3,24 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "node", + "outDir": "dist", + "rootDir": "src", "esModuleInterop": true, "strict": true, - "outDir": "dist", - "rootDir": "./", - "types": ["jest"], // Jest 타입 정의 추가 - "allowSyntheticDefaultImports": true // Babel 사용 시 필요 + "allowSyntheticDefaultImports": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "declaration": true, + "typeRoots": ["./node_modules/@types"], + "baseUrl": "./", + "paths": { + "*": ["src/*"] + } }, - "include": ["src/**/*", "test/**/*"], // 테스트 디렉토리 포함 - "exclude": ["node_modules"] + "include": ["src/**/*"], + "exclude": ["node_modules", "dist", "test"], + "tsc-alias": { + "resolveFullPaths": true, + "resolveFullExtension": ".js" + } } \ No newline at end of file From daff69996c968f179343c91c0296afd1d43b5d4c Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:35:32 +0900 Subject: [PATCH 35/47] =?UTF-8?q?feat:=20=EB=84=A4=EC=9E=84=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20CI/CD=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 49 +++++++++++++----------- backend/name-server/Dockerfile | 33 ++++++++++++++++ backend/name-server/docker-compose.yml | 41 ++++++++++++++++++++ backend/name-server/ecosystem.config.cjs | 10 +++++ backend/name-server/nginx.conf | 17 ++++++++ backend/proxy-server/docker-compose.yml | 2 +- 6 files changed, 128 insertions(+), 24 deletions(-) create mode 100644 backend/name-server/Dockerfile create mode 100644 backend/name-server/docker-compose.yml create mode 100644 backend/name-server/ecosystem.config.cjs create mode 100644 backend/name-server/nginx.conf diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 0aa2eddb..7a31731c 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -18,7 +18,7 @@ jobs: permissions: packages: read - # 콘솔 서버 배포 +# # 콘솔 서버 배포 # deploy-console-server: # needs: setup # uses: ./.github/workflows/deploy-service.yml @@ -33,34 +33,37 @@ jobs: # host: ${{ secrets.CONSOLE_SERVER_HOST }} # env: ${{ secrets.CONSOLE_SERVER_ENV }} # tok: ${{secrets.GHCR_TOKEN}} +# +# # 프록시 서버 배포 +# deploy-proxy-server: +# needs: setup +# uses: ./.github/workflows/deploy-service.yml +# with: +# service: web35-watchducks +# path: backend/proxy-server +# source: "./web35-watchducks/backend/proxy-server/*.yml" +# use_host_nginx: true +# secrets: +# user: ${{ secrets.SSH_USER }} +# port: ${{ secrets.SSH_PORT }} +# key: ${{ secrets.SSH_KEY }} +# host: ${{ secrets.PROXY_SERVER_HOST }} +# env: ${{ secrets.PROXY_SERVER_ENV }} +# tok: ${{secrets.GHCR_TOKEN}} + - # 프록시 서버 배포 - deploy-proxy-server: + # 네임서버 배포 + deploy-name-server: needs: setup uses: ./.github/workflows/deploy-service.yml with: service: web35-watchducks - path: backend/proxy-server - source: "./web35-watchducks/backend/proxy-server/*.yml" - use_host_nginx: true + path: backend/name-server + source: "./web35-watchducks/backend/name-server/*.yml, ./web35-watchducks/backend/name-server/*.conf" secrets: user: ${{ secrets.SSH_USER }} port: ${{ secrets.SSH_PORT }} key: ${{ secrets.SSH_KEY }} - host: ${{ secrets.PROXY_SERVER_HOST }} - env: ${{ secrets.PROXY_SERVER_ENV }} - tok: ${{secrets.GHCR_TOKEN}} - - -# # 네임서버 배포 -# deploy-name-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: name-server -# path: backend/name-server -# key_secret: SSH_KEY -# port_secret: SSH_PORT -# host_secret: NAME_SERVER_HOST -# user_secret: NAME_SERVER_USER -# env_secret: NAME_SERVER_ENV \ No newline at end of file + host: ${{ secrets.NAME_SERVER_HOST }} + env: ${{ secrets.NAME_SERVER_ENV }} + tok: ${{secrets.GHCR_TOKEN}} \ No newline at end of file diff --git a/backend/name-server/Dockerfile b/backend/name-server/Dockerfile new file mode 100644 index 00000000..221149da --- /dev/null +++ b/backend/name-server/Dockerfile @@ -0,0 +1,33 @@ +# 빌드 스테이지 +FROM node:22-alpine AS build + +WORKDIR /usr/src/app + +# 패키지 파일 복사 및 의존성 설치 +COPY package*.json ./ +RUN npm install + +# 소스 코드 복사 및 빌드 +COPY . . +RUN npm run build + +# 런타임 스테이지 +FROM node:22-alpine + +WORKDIR /usr/src/app + +# 프로덕션 의존성 설치 +COPY package*.json ./ +RUN npm install --production + +# 빌드 결과물 복사 +COPY --from=build /usr/src/app/dist ./dist + +# PM2 설치 (옵션) +RUN npm install pm2 -g + +# PM2 설정 파일 복사 (옵션) +COPY ecosystem.config.js ./ + +# 애플리케이션 실행 +CMD ["pm2-runtime", "ecosystem.config.cjs"] \ No newline at end of file diff --git a/backend/name-server/docker-compose.yml b/backend/name-server/docker-compose.yml new file mode 100644 index 00000000..1e538ad5 --- /dev/null +++ b/backend/name-server/docker-compose.yml @@ -0,0 +1,41 @@ +version: '3' +services: + nginx: + image: nginx:latest + ports: + - "5353:5353/udp" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + depends_on: + - server-blue + - server-green + + server-blue: + image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest + container_name: app-server-blue-1 + environment: + - NODE_ENV=production + - NAME_SERVER_PORT=3001 + restart: always + volumes: + - ./.env:/usr/src/app/.env + healthcheck: + test: ["CMD", "nc", "-z", "localhost", "3001"] + interval: 10s + timeout: 2s + retries: 5 + + server-green: + image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest + container_name: app-server-green-1 + environment: + - NODE_ENV=production + - NAME_SERVER_PORT=3002 + restart: always + volumes: + - ./.env:/usr/src/app/.env + healthcheck: + test: ["CMD", "nc", "-z", "localhost", "3002"] + interval: 10s + timeout: 2s + retries: 5 \ No newline at end of file diff --git a/backend/name-server/ecosystem.config.cjs b/backend/name-server/ecosystem.config.cjs new file mode 100644 index 00000000..3ff1d30c --- /dev/null +++ b/backend/name-server/ecosystem.config.cjs @@ -0,0 +1,10 @@ +module.exports = { + apps: [ + { + name: 'name-server', + script: 'dist/index.js', // 빌드된 애플리케이션 진입점 + instances: 'max', // CPU 코어 수에 따라 인스턴스 수 자동 조절 + exec_mode: 'cluster', + }, + ], +}; diff --git a/backend/name-server/nginx.conf b/backend/name-server/nginx.conf new file mode 100644 index 00000000..1fcee735 --- /dev/null +++ b/backend/name-server/nginx.conf @@ -0,0 +1,17 @@ +http { + upstream name_server { + server server-blue:3001 weight=1; + server server-green:3002 backup; + } + + server { + listen 5353 udp; + proxy_pass name_server; + + # DNS 응답을 위한 설정 + proxy_timeout 1s; + proxy_responses 1; # 한 요청당 하나의 응답을 기대 + } +} + +events{} \ No newline at end of file diff --git a/backend/proxy-server/docker-compose.yml b/backend/proxy-server/docker-compose.yml index df5de039..20497aa6 100644 --- a/backend/proxy-server/docker-compose.yml +++ b/backend/proxy-server/docker-compose.yml @@ -27,7 +27,7 @@ services: - ./.env:/usr/src/app/.env network_mode: "host" healthcheck: - test: [ "CMD", "nc", "-z", "localhost", "3001" ] + test: [ "CMD", "nc", "-z", "localhost", "3002" ] interval: 10s timeout: 2s retries: 5 \ No newline at end of file From 2d0420dfe99ac953ac0b169632cd162ff1306f92 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:37:11 +0900 Subject: [PATCH 36/47] =?UTF-8?q?fix:=20=EC=97=90=EC=BD=94=EC=8B=9C?= =?UTF-8?q?=EC=8A=A4=ED=85=9C=20cjs=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/name-server/Dockerfile b/backend/name-server/Dockerfile index 221149da..80c315cf 100644 --- a/backend/name-server/Dockerfile +++ b/backend/name-server/Dockerfile @@ -27,7 +27,7 @@ COPY --from=build /usr/src/app/dist ./dist RUN npm install pm2 -g # PM2 설정 파일 복사 (옵션) -COPY ecosystem.config.js ./ +COPY ecosystem.config.cjs ./ # 애플리케이션 실행 CMD ["pm2-runtime", "ecosystem.config.cjs"] \ No newline at end of file From 5f4be37cae7678b542401c97d5beb7c85b57c601 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:53:42 +0900 Subject: [PATCH 37/47] =?UTF-8?q?fix:=20nginx=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/name-server/nginx.conf b/backend/name-server/nginx.conf index 1fcee735..53af7067 100644 --- a/backend/name-server/nginx.conf +++ b/backend/name-server/nginx.conf @@ -1,4 +1,4 @@ -http { +stream { upstream name_server { server server-blue:3001 weight=1; server server-green:3002 backup; From 5edef536bf1dbe72f5e85e6ec72d1d66bb8353af Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Wed, 13 Nov 2024 23:59:46 +0900 Subject: [PATCH 38/47] =?UTF-8?q?fix:=20=EC=9D=91=EB=8B=B5=20=EA=B8=B0?= =?UTF-8?q?=EB=8C=80=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/name-server/nginx.conf b/backend/name-server/nginx.conf index 53af7067..abfba3f0 100644 --- a/backend/name-server/nginx.conf +++ b/backend/name-server/nginx.conf @@ -10,7 +10,7 @@ stream { # DNS 응답을 위한 설정 proxy_timeout 1s; - proxy_responses 1; # 한 요청당 하나의 응답을 기대 + proxy_responses 0; # 응답 기대하지 않음 } } From dd9e3cccc4d00a0f910612638eb343b822d067e7 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:12:58 +0900 Subject: [PATCH 39/47] =?UTF-8?q?fix:=20=EB=84=A4=ED=8A=B8=EC=9B=8C?= =?UTF-8?q?=ED=81=AC=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/docker-compose.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/name-server/docker-compose.yml b/backend/name-server/docker-compose.yml index 1e538ad5..33cbb032 100644 --- a/backend/name-server/docker-compose.yml +++ b/backend/name-server/docker-compose.yml @@ -9,10 +9,11 @@ services: depends_on: - server-blue - server-green + networks: + - app-network server-blue: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest - container_name: app-server-blue-1 environment: - NODE_ENV=production - NAME_SERVER_PORT=3001 @@ -24,10 +25,11 @@ services: interval: 10s timeout: 2s retries: 5 + networks: + - app-network server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest - container_name: app-server-green-1 environment: - NODE_ENV=production - NAME_SERVER_PORT=3002 @@ -38,4 +40,10 @@ services: test: ["CMD", "nc", "-z", "localhost", "3002"] interval: 10s timeout: 2s - retries: 5 \ No newline at end of file + retries: 5 + networks: + - app-network + +networks: + app-network: + driver: bridge \ No newline at end of file From e721cec83426e54d5c7ca2a9e6449c72e3373d80 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:15:26 +0900 Subject: [PATCH 40/47] =?UTF-8?q?fix:=20=ED=97=AC=EC=8A=A4=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=98=B5=EC=85=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/docker-compose.yml | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/backend/name-server/docker-compose.yml b/backend/name-server/docker-compose.yml index 33cbb032..82a333e0 100644 --- a/backend/name-server/docker-compose.yml +++ b/backend/name-server/docker-compose.yml @@ -9,11 +9,10 @@ services: depends_on: - server-blue - server-green - networks: - - app-network server-blue: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest + container_name: app-server-blue-1 environment: - NODE_ENV=production - NAME_SERVER_PORT=3001 @@ -21,15 +20,14 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-z", "localhost", "3001"] + test: ["CMD", "nc", "-zu", "localhost", "3001"] interval: 10s timeout: 2s retries: 5 - networks: - - app-network server-green: image: ghcr.io/boostcampwm-2024/web35-watchducks/backend/name-server:latest + container_name: app-server-green-1 environment: - NODE_ENV=production - NAME_SERVER_PORT=3002 @@ -37,13 +35,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-z", "localhost", "3002"] + test: ["CMD", "nc", "-zu", "localhost", "3002"] interval: 10s timeout: 2s - retries: 5 - networks: - - app-network - -networks: - app-network: - driver: bridge \ No newline at end of file + retries: 5 \ No newline at end of file From 4f33986c361859d8b63325fea41da34f82f993f3 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:17:38 +0900 Subject: [PATCH 41/47] =?UTF-8?q?fix:=20=ED=97=AC=EC=8A=A4=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=98=B5=EC=85=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/name-server/docker-compose.yml b/backend/name-server/docker-compose.yml index 82a333e0..e5ec4d10 100644 --- a/backend/name-server/docker-compose.yml +++ b/backend/name-server/docker-compose.yml @@ -20,7 +20,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-zu", "localhost", "3001"] + test: ["CMD", "nc", "-u", "localhost", "3001"] interval: 10s timeout: 2s retries: 5 @@ -35,7 +35,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-zu", "localhost", "3002"] + test: ["CMD", "nc", "-u", "localhost", "3002"] interval: 10s timeout: 2s retries: 5 \ No newline at end of file From e4271313b69f976e560a7f47d1a6fc3fce823305 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:19:38 +0900 Subject: [PATCH 42/47] =?UTF-8?q?fix:=20=ED=97=AC=EC=8A=A4=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EC=98=B5=EC=85=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/name-server/docker-compose.yml b/backend/name-server/docker-compose.yml index e5ec4d10..82a333e0 100644 --- a/backend/name-server/docker-compose.yml +++ b/backend/name-server/docker-compose.yml @@ -20,7 +20,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-u", "localhost", "3001"] + test: ["CMD", "nc", "-zu", "localhost", "3001"] interval: 10s timeout: 2s retries: 5 @@ -35,7 +35,7 @@ services: volumes: - ./.env:/usr/src/app/.env healthcheck: - test: ["CMD", "nc", "-u", "localhost", "3002"] + test: ["CMD", "nc", "-zu", "localhost", "3002"] interval: 10s timeout: 2s retries: 5 \ No newline at end of file From fb917d17b9448899073e5aae7547f33ee29b7345 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:31:07 +0900 Subject: [PATCH 43/47] =?UTF-8?q?fix:=20udp=20=ED=8C=A8=ED=82=B7=20?= =?UTF-8?q?=EB=B3=B4=EC=A1=B4=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/nginx.conf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/name-server/nginx.conf b/backend/name-server/nginx.conf index abfba3f0..ab7dd532 100644 --- a/backend/name-server/nginx.conf +++ b/backend/name-server/nginx.conf @@ -9,8 +9,13 @@ stream { proxy_pass name_server; # DNS 응답을 위한 설정 - proxy_timeout 1s; - proxy_responses 0; # 응답 기대하지 않음 + proxy_timeout 3s; + proxy_responses 1; + + # UDP 패킷 보존 설정 + proxy_requests 1; + proxy_socket_keepalive on; + proxy_bind $remote_addr transparent; } } From 3b0a7abc343d3e9e852aa0fe92f5d9967755171e Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 00:37:13 +0900 Subject: [PATCH 44/47] =?UTF-8?q?fix:=20udp=20=ED=8C=A8=ED=82=B7=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/name-server/nginx.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/name-server/nginx.conf b/backend/name-server/nginx.conf index ab7dd532..3660327a 100644 --- a/backend/name-server/nginx.conf +++ b/backend/name-server/nginx.conf @@ -14,8 +14,6 @@ stream { # UDP 패킷 보존 설정 proxy_requests 1; - proxy_socket_keepalive on; - proxy_bind $remote_addr transparent; } } From 9e0af58a92d4bd4293073943db50fc9c5f4bd9e6 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 01:56:23 +0900 Subject: [PATCH 45/47] =?UTF-8?q?chore:=20=EC=84=9C=EB=B2=84=203=EA=B0=9C?= =?UTF-8?q?=20=EB=8F=99=EC=8B=9C=20=EB=B0=B0=ED=8F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci-cd.yml | 64 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7a31731c..2d79a118 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -18,38 +18,38 @@ jobs: permissions: packages: read -# # 콘솔 서버 배포 -# deploy-console-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: web35-watchducks -# path: backend/console-server -# source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" -# secrets: -# user: ${{ secrets.SSH_USER }} -# port: ${{ secrets.SSH_PORT }} -# key: ${{ secrets.SSH_KEY }} -# host: ${{ secrets.CONSOLE_SERVER_HOST }} -# env: ${{ secrets.CONSOLE_SERVER_ENV }} -# tok: ${{secrets.GHCR_TOKEN}} -# -# # 프록시 서버 배포 -# deploy-proxy-server: -# needs: setup -# uses: ./.github/workflows/deploy-service.yml -# with: -# service: web35-watchducks -# path: backend/proxy-server -# source: "./web35-watchducks/backend/proxy-server/*.yml" -# use_host_nginx: true -# secrets: -# user: ${{ secrets.SSH_USER }} -# port: ${{ secrets.SSH_PORT }} -# key: ${{ secrets.SSH_KEY }} -# host: ${{ secrets.PROXY_SERVER_HOST }} -# env: ${{ secrets.PROXY_SERVER_ENV }} -# tok: ${{secrets.GHCR_TOKEN}} + # 콘솔 서버 배포 + deploy-console-server: + needs: setup + uses: ./.github/workflows/deploy-service.yml + with: + service: web35-watchducks + path: backend/console-server + source: "./web35-watchducks/backend/console-server/*.yml, ./web35-watchducks/backend/console-server/*.conf" + secrets: + user: ${{ secrets.SSH_USER }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.CONSOLE_SERVER_HOST }} + env: ${{ secrets.CONSOLE_SERVER_ENV }} + tok: ${{secrets.GHCR_TOKEN}} + + # 프록시 서버 배포 + deploy-proxy-server: + needs: setup + uses: ./.github/workflows/deploy-service.yml + with: + service: web35-watchducks + path: backend/proxy-server + source: "./web35-watchducks/backend/proxy-server/*.yml" + use_host_nginx: true + secrets: + user: ${{ secrets.SSH_USER }} + port: ${{ secrets.SSH_PORT }} + key: ${{ secrets.SSH_KEY }} + host: ${{ secrets.PROXY_SERVER_HOST }} + env: ${{ secrets.PROXY_SERVER_ENV }} + tok: ${{secrets.GHCR_TOKEN}} # 네임서버 배포 From a9f3efe9348c1b0aadba72fb3a5ac9fb35516a59 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 01:59:39 +0900 Subject: [PATCH 46/47] =?UTF-8?q?chore:=20=EC=BD=98=EC=86=94=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=ED=97=AC=EC=8A=A4=EC=B2=B4=ED=81=AC=20=EC=8B=9C?= =?UTF-8?q?=EA=B0=84=20=EC=A6=9D=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/console-server/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 3222518d..108d2477 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -21,7 +21,7 @@ services: - ./.env:/usr/src/app/.env healthcheck: test: ["CMD", "nc", "-z", "localhost", "3001"] - interval: 10s + interval: 20s timeout: 2s retries: 5 From af6cda54b26e682d6a8b004f1d72b07f9a558114 Mon Sep 17 00:00:00 2001 From: sjy2335 Date: Thu, 14 Nov 2024 02:08:57 +0900 Subject: [PATCH 47/47] =?UTF-8?q?fix:=20=ED=97=AC=EC=8A=A4=EC=B2=B4?= =?UTF-8?q?=ED=81=AC=20=EB=B0=98=EB=B3=B5=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-service.yml | 46 ++++++++++++++++------- backend/console-server/docker-compose.yml | 2 +- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy-service.yml b/.github/workflows/deploy-service.yml index 60392b61..eec4e1ca 100644 --- a/.github/workflows/deploy-service.yml +++ b/.github/workflows/deploy-service.yml @@ -105,20 +105,30 @@ jobs: if [ "${{ inputs.use_host_nginx }}" == "true" ]; then # Dockerized Nginx 없이 Blue 컨테이너만 시작 docker-compose up -d --no-deps server-blue - sleep 10 - # Blue 인스턴스 헬스 체크 + # Blue 인스턴스 헬스 체크 - 최대 5번 시도 echo "Blue 컨테이너 헬스 상태 확인 중..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') - if [ "$health_status" == "healthy" ]; then - echo "Blue 컨테이너가 정상 상태입니다." - else + for i in {1..5}; do + health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') + if [ "$health_status" == "healthy" ]; then + echo "Blue 컨테이너가 정상 상태입니다." + break + else + echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다. 시도 $i/5..." + sleep 10 + fi + done + + # 최종 헬스 상태 확인 + if [ "$health_status" != "healthy" ]; then echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." exit 1 fi + + # Nginx 재로드 sudo nginx -s reload echo "호스트 Nginx 리로드 완료로 트래픽 전환 완료" - + else # 콘솔 서버의 Dockerized Nginx 설정 docker-compose up -d --no-deps nginx @@ -126,20 +136,28 @@ jobs: # Dockerized Nginx와 함께 Blue 컨테이너 시작 docker-compose up -d --no-deps server-blue - sleep 10 - - # Blue 인스턴스 헬스 체크 + # Blue 인스턴스 헬스 체크 - 최대 5번 시도 echo "Blue 컨테이너 헬스 상태 확인 중..." - health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') - if [ "$health_status" == "healthy" ]; then - echo "Blue 컨테이너가 정상 상태입니다." - else + for i in {1..5}; do + health_status=$(docker inspect --format='{{json .State.Health.Status}}' app-server-blue-1 | tr -d '"') + if [ "$health_status" == "healthy" ]; then + echo "Blue 컨테이너가 정상 상태입니다." + break + else + echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다. 시도 $i/5..." + sleep 10 + fi + done + + # 최종 헬스 상태 확인 + if [ "$health_status" != "healthy" ]; then echo "Blue 컨테이너가 정상 상태로 전환되지 않았습니다." exit 1 fi # Dockerized Nginx 리로드로 트래픽 전환 docker-compose exec nginx nginx -s reload + echo "Dockerized Nginx 리로드 완료로 트래픽 전환 완료" fi # Green 컨테이너 시작 (두 설정 모두에서 수행) diff --git a/backend/console-server/docker-compose.yml b/backend/console-server/docker-compose.yml index 108d2477..3222518d 100644 --- a/backend/console-server/docker-compose.yml +++ b/backend/console-server/docker-compose.yml @@ -21,7 +21,7 @@ services: - ./.env:/usr/src/app/.env healthcheck: test: ["CMD", "nc", "-z", "localhost", "3001"] - interval: 20s + interval: 10s timeout: 2s retries: 5