From d071098f9a4d4099a8e10bb01bb759600f757157 Mon Sep 17 00:00:00 2001 From: suyeoniii Date: Tue, 8 Apr 2025 20:41:34 +0900 Subject: [PATCH 1/4] =?UTF-8?q?Ci:=20dev=20workflow=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-deploy.yml | 71 +++++++++++++++++--------------- Dockerrun.dev.json | 12 ++++++ 2 files changed, 49 insertions(+), 34 deletions(-) create mode 100644 Dockerrun.dev.json diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index ac96e92..4e31763 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -1,16 +1,15 @@ -name: Dev Deploy to Amazon ECS +name: Dev Deploy to Elastic Beanstalk on: push: - branches: [ "develop" ] + branches: [ "feature/#143" ] env: AWS_REGION: ap-northeast-2 ECR_REPOSITORY: routebox-dev - ECS_SERVICE: routebox-service-dev - ECS_CLUSTER: routebox-dev-cluster - ECS_TASK_DEFINITION: routebox-task-definition-dev.json - CONTAINER_NAME: routebox-dev + EB_APP_NAME: routebox-dev + EB_ENV_NAME: Routebox-dev-env + DOCKER_IMAGE_TAG: ${{ github.sha }} permissions: contents: read @@ -36,7 +35,7 @@ jobs: - name: Copy Secret env: - CREATE_SECRET: ${{secrets.ENV_DEV}} + CREATE_SECRET: ${{ secrets.ENV_DEV }} CREATE_SECRET_DIR: src/main/resources CREATE_SECRET_DIR_FILE_NAME: env.properties run: echo $CREATE_SECRET | base64 --decode > $CREATE_SECRET_DIR/$CREATE_SECRET_DIR_FILE_NAME @@ -45,7 +44,7 @@ jobs: run: ./gradlew build - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 + uses: aws-actions/configure-aws-credentials@v2 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} @@ -53,33 +52,37 @@ jobs: - name: Login to Amazon ECR id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + run: | + aws ecr get-login-password --region $AWS_REGION | \ + docker login --username AWS --password-stdin ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com - - name: Build, tag, and push image to Amazon ECR + - name: Build, tag, and push Docker image to Amazon ECR id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT - - - name: Fill in the new image ID in the Amazon ECS task definition - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: ${{ env.ECS_TASK_DEFINITION }} - container-name: ${{ env.CONTAINER_NAME }} - image: ${{ steps.build-image.outputs.image }} + IMAGE_URI=${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.$AWS_REGION.amazonaws.com/$ECR_REPOSITORY:$DOCKER_IMAGE_TAG + docker build -t $IMAGE_URI . + docker push $IMAGE_URI + echo "image=$IMAGE_URI" >> $GITHUB_OUTPUT - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - service: ${{ env.ECS_SERVICE }} - cluster: ${{ env.ECS_CLUSTER }} - wait-for-service-stability: true + - name: Copy Dockerrun for current branch + run: | + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + cp Dockerrun.prod.json Dockerrun.aws.json + else + cp Dockerrun.dev.json Dockerrun.aws.json + fi + + - name: Install EB CLI + run: | + pip install awsebcli + + - name: Initialize EB CLI + run: | + eb init $EB_APP_NAME \ + --platform docker \ + --region $AWS_REGION \ + --no-interactive + + - name: Deploy to Elastic Beanstalk + run: | + eb deploy $EB_ENV_NAME --staged --verbose diff --git a/Dockerrun.dev.json b/Dockerrun.dev.json new file mode 100644 index 0000000..e357138 --- /dev/null +++ b/Dockerrun.dev.json @@ -0,0 +1,12 @@ +{ + "AWSEBDockerrunVersion": "1", + "Image": { + "Name": "445570920688.dkr.ecr.ap-northeast-2.amazonaws.com/routebox-dev:latest", + "Update": "true" + }, + "Ports": [ + { + "ContainerPort": 8080 + } + ] +} From 7867e4835d1ab6cddb90b40248998dd210890e6c Mon Sep 17 00:00:00 2001 From: suyeoniii Date: Tue, 8 Apr 2025 20:52:52 +0900 Subject: [PATCH 2/4] =?UTF-8?q?Ci:=20dev=20workflow=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .elasticbeanstalk/config.yml | 9 +++++++++ .github/workflows/dev-deploy.yml | 9 +-------- 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 .elasticbeanstalk/config.yml diff --git a/.elasticbeanstalk/config.yml b/.elasticbeanstalk/config.yml new file mode 100644 index 0000000..93a7979 --- /dev/null +++ b/.elasticbeanstalk/config.yml @@ -0,0 +1,9 @@ +branch-defaults: + develop: + environment: Routebox-dev-env + main: + environment: Routebox-prod-env +global: + application_name: routebox + default_region: ap-northeast-2 + platform: Docker diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index 4e31763..3069f6f 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -7,7 +7,7 @@ on: env: AWS_REGION: ap-northeast-2 ECR_REPOSITORY: routebox-dev - EB_APP_NAME: routebox-dev + EB_APP_NAME: routebox EB_ENV_NAME: Routebox-dev-env DOCKER_IMAGE_TAG: ${{ github.sha }} @@ -76,13 +76,6 @@ jobs: run: | pip install awsebcli - - name: Initialize EB CLI - run: | - eb init $EB_APP_NAME \ - --platform docker \ - --region $AWS_REGION \ - --no-interactive - - name: Deploy to Elastic Beanstalk run: | eb deploy $EB_ENV_NAME --staged --verbose From 65a4eafc3787577731267eafdf46654995a59854 Mon Sep 17 00:00:00 2001 From: suyeoniii Date: Tue, 8 Apr 2025 21:11:43 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Ci:=20dev=20workflow=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-deploy.yml | 20 ++++++++++---------- Dockerrun.dev.json | 12 ------------ docker-compose.dev.yml | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 Dockerrun.dev.json create mode 100644 docker-compose.dev.yml diff --git a/.github/workflows/dev-deploy.yml b/.github/workflows/dev-deploy.yml index 3069f6f..f00d714 100644 --- a/.github/workflows/dev-deploy.yml +++ b/.github/workflows/dev-deploy.yml @@ -50,6 +50,9 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ env.AWS_REGION }} + - name: Copy dev compose file + run: cp docker-compose.dev.yml docker-compose.yml + - name: Login to Amazon ECR id: login-ecr run: | @@ -64,18 +67,15 @@ jobs: docker push $IMAGE_URI echo "image=$IMAGE_URI" >> $GITHUB_OUTPUT - - name: Copy Dockerrun for current branch + - name: Install EB CLI run: | - if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - cp Dockerrun.prod.json Dockerrun.aws.json - else - cp Dockerrun.dev.json Dockerrun.aws.json - fi + pip install --upgrade --user awsebcli + echo "$HOME/.local/bin" >> $GITHUB_PATH - - name: Install EB CLI + - name: EB Init run: | - pip install awsebcli + eb init ${{ env.EB_APP_NAME }} --platform "Docker running on 64bit Amazon Linux 2023" --region ${{ env.AWS_REGION }} + eb use ${{ env.EB_ENV_NAME }} - name: Deploy to Elastic Beanstalk - run: | - eb deploy $EB_ENV_NAME --staged --verbose + run: eb deploy --staged --verbose diff --git a/Dockerrun.dev.json b/Dockerrun.dev.json deleted file mode 100644 index e357138..0000000 --- a/Dockerrun.dev.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "AWSEBDockerrunVersion": "1", - "Image": { - "Name": "445570920688.dkr.ecr.ap-northeast-2.amazonaws.com/routebox-dev:latest", - "Update": "true" - }, - "Ports": [ - { - "ContainerPort": 8080 - } - ] -} diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..0a99696 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,14 @@ +version: '3.8' + +services: + app: + build: + context: . + dockerfile: Dockerfile + image: routebox-dev:latest + ports: + - "8080:8080" + environment: + SPRING_PROFILES_ACTIVE: dev + TZ: Asia/Seoul + restart: always From 0606cb1b86044254cbf8dbfaada29cd235c5d930 Mon Sep 17 00:00:00 2001 From: suyeoniii Date: Sun, 13 Apr 2025 20:44:00 +0900 Subject: [PATCH 4/4] =?UTF-8?q?Fix:=20=ED=8F=AC=EC=9D=B8=ED=8A=B8=20?= =?UTF-8?q?=EA=B5=AC=EB=A7=A4=ED=95=98=EA=B8=B0=20=EC=98=A4=EB=A5=98=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 --- .../com/routebox/routebox/controller/route/RouteController.kt | 3 +-- .../kotlin/com/routebox/routebox/domain/user/UserService.kt | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/routebox/routebox/controller/route/RouteController.kt b/src/main/kotlin/com/routebox/routebox/controller/route/RouteController.kt index bb3124e..77439f9 100644 --- a/src/main/kotlin/com/routebox/routebox/controller/route/RouteController.kt +++ b/src/main/kotlin/com/routebox/routebox/controller/route/RouteController.kt @@ -99,8 +99,7 @@ class RouteController( @Operation( summary = "루트 구매하기", description = "

루트를 구매합니다. 루트는 쿠폰과 포인트를 사용하여 구매할 수 있습니다." + - "

쿠폰을 사용하여 루트를 구매할 경우, 이용 종료일이 얼마 남지 않은 쿠폰이 자동으로 사용됩니다" + - "

포인트를 사용하여 루트를 구매하는 기능은 현재 미구현 상태입니다. (추후 구현 예정)", + "

쿠폰을 사용하여 루트를 구매할 경우, 이용 종료일이 얼마 남지 않은 쿠폰이 자동으로 사용됩니다", security = [SecurityRequirement(name = "access-token")], ) @ApiResponses( diff --git a/src/main/kotlin/com/routebox/routebox/domain/user/UserService.kt b/src/main/kotlin/com/routebox/routebox/domain/user/UserService.kt index 5763cd3..56c781d 100644 --- a/src/main/kotlin/com/routebox/routebox/domain/user/UserService.kt +++ b/src/main/kotlin/com/routebox/routebox/domain/user/UserService.kt @@ -140,7 +140,7 @@ class UserService( @Transactional fun usePoint(userId: Long, point: Int): User { val user = getUserById(userId) - if (user.canPurchase(point)) { + if (!user.canPurchase(point)) { throw InsufficientPointException() } user.usePoint(point)