From d0a376888fe0eb6bc1c3a0fdf09a425d8b386d84 Mon Sep 17 00:00:00 2001 From: rlaxxwls13 Date: Wed, 13 May 2026 16:01:37 +0900 Subject: [PATCH 1/4] =?UTF-8?q?chore:=20queue-service=20ECS=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EC=84=A4=EC=A0=95=20dquote>=20-=20ECS=20Fargate=20?= =?UTF-8?q?=ED=99=98=EA=B2=BD=EC=97=90=EC=84=9C=20Eureka=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20IP=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= =?UTF-8?q?=EC=9D=84=20=EC=9C=84=ED=95=B4=20=20=20spring.cloud.inetutils.p?= =?UTF-8?q?referred-networks=20=EC=B6=94=EA=B0=80=20-=20Docker=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EB=B9=8C=EB=93=9C=20=EC=9B=8C=ED=81=AC?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=B6=94=EA=B0=80=20(BuildKit=20?= =?UTF-8?q?Secret=EC=9C=BC=EB=A1=9C=20GitHub=20Packages=20=EC=9D=B8?= =?UTF-8?q?=EC=A6=9D)=20-=20=EA=B8=B0=EC=A1=B4=20ci.yml=EC=9D=80=20deploy.?= =?UTF-8?q?yml=EB=A1=9C=20=ED=86=B5=ED=95=A9=EB=90=98=EC=96=B4=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #28 --- .github/workflows/ci.yml | 53 ---------------- .github/workflows/deploy.yml | 99 ++++++++++++++++++++++++++++++ src/main/resources/application.yml | 9 +++ 3 files changed, 108 insertions(+), 53 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index f15626c..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CI - -on: - pull_request: - branches: - - main - - dev - push: - branches: - - main - - dev - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up JDK 21 - uses: actions/setup-java@v4 - with: - java-version: '21' - distribution: 'temurin' - - - name: Set up Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Grant execute permission to gradlew - run: chmod +x gradlew - - - name: Gradle Build - env: - GITHUB_USER: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build docs --no-daemon - - - name: Upload REST Docs - if: success() - uses: actions/upload-artifact@v4 - with: - name: rest-docs - path: build/docs/asciidoc/ - retention-days: 7 - - - name: Upload test report (on failure) - if: failure() - uses: actions/upload-artifact@v4 - with: - name: test-report - path: build/reports/tests/ - retention-days: 7 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..4347533 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,99 @@ +name: CI/CD - Build, Test, and Deploy + +on: + pull_request: + branches: + - main + - dev + push: + branches: + - main + - dev + - chore/28-deploy + workflow_dispatch: + +permissions: + id-token: write # OIDC AWS 인증용 + contents: read # 코드 체크아웃 + packages: read # GitHub Packages (common 모듈) 읽기 + +env: + AWS_REGION: ap-northeast-2 + ECR_REPOSITORY: first-ticket/queue-service + # GitHub Actions 자동 제공 토큰 - common 모듈 접근용 + GITHUB_USER: ${{ github.actor }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + # 1) 빌드 + 테스트 (모든 PR/push에서 실행) + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up JDK 21 + uses: actions/setup-java@v5 + with: + java-version: '21' + distribution: 'temurin' + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v6 + + - name: Grant execute permission to gradlew + run: chmod +x gradlew + + - name: Build & Test + run: ./gradlew build --no-daemon + + - name: Upload test report (on failure) + if: failure() + uses: actions/upload-artifact@v5 + with: + name: test-report + path: build/reports/tests/ + retention-days: 7 + + # 2) ECR 푸시 (main 또는 작업 브랜치 push 시) + push-to-ecr: + needs: build-and-test + if: | + github.event_name == 'push' && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/chore/28-deploy') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Configure AWS credentials (OIDC) + uses: aws-actions/configure-aws-credentials@v6 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: ecr-login + uses: aws-actions/amazon-ecr-login@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build, tag, and push image to ECR + env: + REGISTRY: ${{ steps.ecr-login.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} + run: | + docker buildx build --platform linux/amd64 \ + --build-arg GITHUB_USER=${{ github.actor }} \ + --secret id=github_token,env=GITHUB_TOKEN \ + -t $REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG \ + -t $REGISTRY/$ECR_REPOSITORY:latest \ + --push \ + . + + - name: Show pushed image + run: | + echo "✅ Pushed: $ECR_REPOSITORY:${{ github.sha }}" + echo "✅ Pushed: $ECR_REPOSITORY:latest" diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 23061c2..5603b2f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -6,7 +6,16 @@ spring: import: - "optional:file:.env[.properties]" - "optional:configserver:" + cloud: + # ECS Fargate에서 Eureka에 자기 IP를 ECS 메타데이터 IP(169.254.172.2)가 아닌 VPC 내부 IP(172.31.x.x)로 등록되게 하기 위한 설정. + # InetUtils가 IP 선택 시점이 Config Server 받기 전이라 + inetutils: + preferred-networks: + - 10\. + - 172\. + - 192\.168\. + config: username: ${CONFIG_SERVER_USERNAME:} password: ${CONFIG_SERVER_PASSWORD:} From 42369f10127fefc134d0e7e15138f93581b257cb Mon Sep 17 00:00:00 2001 From: rlaxxwls13 Date: Wed, 13 May 2026 22:58:43 +0900 Subject: [PATCH 2/4] =?UTF-8?q?chore:=20ecs=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #28 --- .github/workflows/deploy.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4347533..32fc909 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -97,3 +97,16 @@ jobs: run: | echo "✅ Pushed: $ECR_REPOSITORY:${{ github.sha }}" echo "✅ Pushed: $ECR_REPOSITORY:latest" + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition queue-service \ + --query taskDefinition > task-definition.json + + - name: Deploy to ECS + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 + with: + task-definition: task-definition.json + service: queue-service-service + cluster: first-ticket-cluster + wait-for-service-stability: false From 859c0d82827549c83881033b686a9d76780c8513 Mon Sep 17 00:00:00 2001 From: rlaxxwls13 Date: Wed, 13 May 2026 23:08:39 +0900 Subject: [PATCH 3/4] =?UTF-8?q?chore:=20deploy.yml=EC=97=90=20=EC=9E=91?= =?UTF-8?q?=EC=97=85=EB=B8=8C=EB=9E=9C=EC=B9=98=20=ED=8A=B8=EB=A6=AC?= =?UTF-8?q?=EA=B1=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #28 --- .github/workflows/deploy.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 32fc909..88d1ac3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,7 +9,6 @@ on: branches: - main - dev - - chore/28-deploy workflow_dispatch: permissions: @@ -56,12 +55,10 @@ jobs: path: build/reports/tests/ retention-days: 7 - # 2) ECR 푸시 (main 또는 작업 브랜치 push 시) + # 2) ECR 푸시 (main 브랜치 push 시) push-to-ecr: needs: build-and-test - if: | - github.event_name == 'push' && - (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/chore/28-deploy') + if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: From bd98fccd2ff02470a3a424bdd931a9652549a131 Mon Sep 17 00:00:00 2001 From: rlaxxwls13 Date: Wed, 13 May 2026 23:21:57 +0900 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=EC=95=A1=EC=85=98=20=EB=B2=84?= =?UTF-8?q?=EC=A0=84=20=EC=97=85=EA=B7=B8=EB=A0=88=EC=9D=B4=EB=93=9C=20-?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=EB=9E=98=EB=B9=97=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Related to #28 --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 88d1ac3..7e969ee 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,7 +49,7 @@ jobs: - name: Upload test report (on failure) if: failure() - uses: actions/upload-artifact@v5 + uses: actions/upload-artifact@v7 with: name: test-report path: build/reports/tests/ @@ -75,7 +75,7 @@ jobs: uses: aws-actions/amazon-ecr-login@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + uses: docker/setup-buildx-action@v4 - name: Build, tag, and push image to ECR env: