From 15bb6c2afdd6637f56e68c05711e7e850b08578e Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:09:00 +0900 Subject: [PATCH 1/6] =?UTF-8?q?CI=20:=20prod=20db=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-prod/00-makeFiles.config | 8 +++ .ebextensions-prod/00-set-timezone.config | 3 + .ebextensions-prod/01_set_up_swap.config | 26 ++++++++ .github/workflows/prod-ci-cd.yml | 76 +++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 .ebextensions-prod/00-makeFiles.config create mode 100644 .ebextensions-prod/00-set-timezone.config create mode 100644 .ebextensions-prod/01_set_up_swap.config create mode 100644 .github/workflows/prod-ci-cd.yml diff --git a/.ebextensions-prod/00-makeFiles.config b/.ebextensions-prod/00-makeFiles.config new file mode 100644 index 0000000..dde4486 --- /dev/null +++ b/.ebextensions-prod/00-makeFiles.config @@ -0,0 +1,8 @@ +files: + "/sbin/appstart" : + mode: "000755" + owner: webapp + group: webapp + content: | + kill `ps -ef | grep cmc-dev-api | awk '{print $2}'` + java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-prod-api.jar diff --git a/.ebextensions-prod/00-set-timezone.config b/.ebextensions-prod/00-set-timezone.config new file mode 100644 index 0000000..869275c --- /dev/null +++ b/.ebextensions-prod/00-set-timezone.config @@ -0,0 +1,3 @@ +commands: + set_time_zone: + command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime \ No newline at end of file diff --git a/.ebextensions-prod/01_set_up_swap.config b/.ebextensions-prod/01_set_up_swap.config new file mode 100644 index 0000000..6b82f6f --- /dev/null +++ b/.ebextensions-prod/01_set_up_swap.config @@ -0,0 +1,26 @@ +files: + "/home/ec2-user/setup_swap.sh": + mode: "000755" + owner: root + group: root + content: | + #!/bin/bash + # based on http://steinn.org/post/elasticbeanstalk-swap/ + + SWAPFILE=/var/swapfile + SWAP_MEGABYTES=2048 + + if [ -f $SWAPFILE ]; then + echo "Swapfile $SWAPFILE found, assuming already setup" + exit; + fi + + /bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES + /bin/chmod 600 $SWAPFILE + /sbin/mkswap $SWAPFILE + /sbin/swapon $SWAPFILE + +commands: + 01setup_swap: + command: "bash setup_swap.sh" + cwd: "/home/ec2-user/" diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml new file mode 100644 index 0000000..cb2d85f --- /dev/null +++ b/.github/workflows/prod-ci-cd.yml @@ -0,0 +1,76 @@ +name: prod CMC API Server BeanStalk CI/CD + +on: + push: + branches: [ prod ] + workflow_dispatch: # 수동 실행 옵션 (생략) + +jobs: + build: + runs-on: ubuntu-latest # action 스크립트가 작동될 OS + + steps: # 작업 단계 + - name: Checkout source code # 단계별 이름, 구분자로 소스를 가져옴 + uses: actions/checkout@v2 + + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + + - name: Set Environment - Common Yml + uses: microsoft/variable-substitution@v1 + with: + files: src/main/resources/application-common.yml + env: + jwt.secret: ${{ secrets.JWT_SECRET_KEY }} + jwt.refresh: ${{ secrets.JWT_REFRESH_KEY }} + spring.mail.password: ${{ secrets.MAIL_PASSWORD}} + + - name: Set Environment Domain - Domain PROD Yml + uses: microsoft/variable-substitution@v1 + with: + files: src/main/resources/application-domain-prod.yml + env: + spring.datasource.url: ${{ secrets.PROD_DB_URL_HOST }} + spring.datasource.username: ${{ secrets.AWS_DB_USER_NAME }} + spring.datasource.password: ${{ secrets.AWS_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.PROD_REDIS_HOST }} + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Build with Gradle + run: ./gradlew build + shell: bash + + - name: Get current time + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYYMMDDTHHmm + utcOffset: "+09:00" + + - name: Generate deployment package + run: | + mkdir -p deploy + cp build/libs/*.jar deploy/cmc-prod-api.jar + cp Procfile deploy/Procfile + cp -r .ebextensions-prod deploy/.ebextensions + cp -r .platform deploy/.platform + cd deploy && zip -r cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} . + + - name: Deploy Consumer to EB + uses: einaregilsson/beanstalk-deploy@v19 + with: + aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} + aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} + application_name: CmcApiServerDev + environment_name: CmcApiServerDev-env + version_label: cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} + region: ap-northeast-2 + deployment_package: deploy/cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}}.zip + wait_for_deployment: false \ No newline at end of file From 040f94fc40631ebc8c8168921236c8cfa78f04da Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:09:00 +0900 Subject: [PATCH 2/6] =?UTF-8?q?CI=20:=20prod=20db=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-prod/00-makeFiles.config | 8 +++ .ebextensions-prod/00-set-timezone.config | 3 + .ebextensions-prod/01_set_up_swap.config | 26 ++++++++ .github/workflows/prod-ci-cd.yml | 76 +++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 .ebextensions-prod/00-makeFiles.config create mode 100644 .ebextensions-prod/00-set-timezone.config create mode 100644 .ebextensions-prod/01_set_up_swap.config create mode 100644 .github/workflows/prod-ci-cd.yml diff --git a/.ebextensions-prod/00-makeFiles.config b/.ebextensions-prod/00-makeFiles.config new file mode 100644 index 0000000..dde4486 --- /dev/null +++ b/.ebextensions-prod/00-makeFiles.config @@ -0,0 +1,8 @@ +files: + "/sbin/appstart" : + mode: "000755" + owner: webapp + group: webapp + content: | + kill `ps -ef | grep cmc-dev-api | awk '{print $2}'` + java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-prod-api.jar diff --git a/.ebextensions-prod/00-set-timezone.config b/.ebextensions-prod/00-set-timezone.config new file mode 100644 index 0000000..869275c --- /dev/null +++ b/.ebextensions-prod/00-set-timezone.config @@ -0,0 +1,3 @@ +commands: + set_time_zone: + command: ln -f -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime \ No newline at end of file diff --git a/.ebextensions-prod/01_set_up_swap.config b/.ebextensions-prod/01_set_up_swap.config new file mode 100644 index 0000000..6b82f6f --- /dev/null +++ b/.ebextensions-prod/01_set_up_swap.config @@ -0,0 +1,26 @@ +files: + "/home/ec2-user/setup_swap.sh": + mode: "000755" + owner: root + group: root + content: | + #!/bin/bash + # based on http://steinn.org/post/elasticbeanstalk-swap/ + + SWAPFILE=/var/swapfile + SWAP_MEGABYTES=2048 + + if [ -f $SWAPFILE ]; then + echo "Swapfile $SWAPFILE found, assuming already setup" + exit; + fi + + /bin/dd if=/dev/zero of=$SWAPFILE bs=1M count=$SWAP_MEGABYTES + /bin/chmod 600 $SWAPFILE + /sbin/mkswap $SWAPFILE + /sbin/swapon $SWAPFILE + +commands: + 01setup_swap: + command: "bash setup_swap.sh" + cwd: "/home/ec2-user/" diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml new file mode 100644 index 0000000..cb2d85f --- /dev/null +++ b/.github/workflows/prod-ci-cd.yml @@ -0,0 +1,76 @@ +name: prod CMC API Server BeanStalk CI/CD + +on: + push: + branches: [ prod ] + workflow_dispatch: # 수동 실행 옵션 (생략) + +jobs: + build: + runs-on: ubuntu-latest # action 스크립트가 작동될 OS + + steps: # 작업 단계 + - name: Checkout source code # 단계별 이름, 구분자로 소스를 가져옴 + uses: actions/checkout@v2 + + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + + - name: Set Environment - Common Yml + uses: microsoft/variable-substitution@v1 + with: + files: src/main/resources/application-common.yml + env: + jwt.secret: ${{ secrets.JWT_SECRET_KEY }} + jwt.refresh: ${{ secrets.JWT_REFRESH_KEY }} + spring.mail.password: ${{ secrets.MAIL_PASSWORD}} + + - name: Set Environment Domain - Domain PROD Yml + uses: microsoft/variable-substitution@v1 + with: + files: src/main/resources/application-domain-prod.yml + env: + spring.datasource.url: ${{ secrets.PROD_DB_URL_HOST }} + spring.datasource.username: ${{ secrets.AWS_DB_USER_NAME }} + spring.datasource.password: ${{ secrets.AWS_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.PROD_REDIS_HOST }} + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Build with Gradle + run: ./gradlew build + shell: bash + + - name: Get current time + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYYMMDDTHHmm + utcOffset: "+09:00" + + - name: Generate deployment package + run: | + mkdir -p deploy + cp build/libs/*.jar deploy/cmc-prod-api.jar + cp Procfile deploy/Procfile + cp -r .ebextensions-prod deploy/.ebextensions + cp -r .platform deploy/.platform + cd deploy && zip -r cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} . + + - name: Deploy Consumer to EB + uses: einaregilsson/beanstalk-deploy@v19 + with: + aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} + aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} + application_name: CmcApiServerDev + environment_name: CmcApiServerDev-env + version_label: cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} + region: ap-northeast-2 + deployment_package: deploy/cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}}.zip + wait_for_deployment: false \ No newline at end of file From 7eaf217899a0169f92c1ed98eeeeb9952441b109 Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:17:42 +0900 Subject: [PATCH 3/6] =?UTF-8?q?CI=20:=20prod=20db=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-prod/00-makeFiles.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ebextensions-prod/00-makeFiles.config b/.ebextensions-prod/00-makeFiles.config index dde4486..768108d 100644 --- a/.ebextensions-prod/00-makeFiles.config +++ b/.ebextensions-prod/00-makeFiles.config @@ -4,5 +4,5 @@ files: owner: webapp group: webapp content: | - kill `ps -ef | grep cmc-dev-api | awk '{print $2}'` + kill `ps -ef | grep cmc-prod-api | awk '{print $2}'` java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-prod-api.jar From 8cf7387237021a4254a9c7dbb44b3b02771ecf43 Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:27:43 +0900 Subject: [PATCH 4/6] =?UTF-8?q?CI=20:=20prod=20db=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-prod/00-makeFiles.config | 4 ++-- .github/workflows/prod-ci-cd.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ebextensions-prod/00-makeFiles.config b/.ebextensions-prod/00-makeFiles.config index 768108d..bf7955e 100644 --- a/.ebextensions-prod/00-makeFiles.config +++ b/.ebextensions-prod/00-makeFiles.config @@ -4,5 +4,5 @@ files: owner: webapp group: webapp content: | - kill `ps -ef | grep cmc-prod-api | awk '{print $2}'` - java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-prod-api.jar + kill `ps -ef | grep cmc-dev-api | awk '{print $2}'` + java -Dspring.profiles.active=prod -Dfile.encoding=UTF-8 -jar /var/app/current/cmc-dev-api.jar diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index cb2d85f..b5b35b4 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -57,11 +57,11 @@ jobs: - name: Generate deployment package run: | mkdir -p deploy - cp build/libs/*.jar deploy/cmc-prod-api.jar + cp build/libs/*.jar deploy/cmc-dev-api.jar cp Procfile deploy/Procfile cp -r .ebextensions-prod deploy/.ebextensions cp -r .platform deploy/.platform - cd deploy && zip -r cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} . + cd deploy && zip -r cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} . - name: Deploy Consumer to EB uses: einaregilsson/beanstalk-deploy@v19 @@ -70,7 +70,7 @@ jobs: aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} application_name: CmcApiServerDev environment_name: CmcApiServerDev-env - version_label: cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} + version_label: cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}} region: ap-northeast-2 - deployment_package: deploy/cmc-prod-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}}.zip + deployment_package: deploy/cmc-dev-api-${{steps.current-time.outputs.formattedTime}}-${{github.sha}}.zip wait_for_deployment: false \ No newline at end of file From bd5dd809beb4dd1c6c3996fbacd7420643fec745 Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:37:29 +0900 Subject: [PATCH 5/6] =?UTF-8?q?CI=20:=20prod=20db=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/prod-ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index b5b35b4..5e0bf7a 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -37,7 +37,7 @@ jobs: spring.datasource.url: ${{ secrets.PROD_DB_URL_HOST }} spring.datasource.username: ${{ secrets.AWS_DB_USER_NAME }} spring.datasource.password: ${{ secrets.AWS_DB_PASSWORD }} - spring.data.redis.host: ${{ secrets.PROD_REDIS_HOST }} + spring.data.redis.host: ${{ secrets.DEV_REDIS_HOST }} - name: Grant execute permission for gradlew run: chmod +x ./gradlew From ab255f42d5e59c6c63e1c700c800fd37090707a7 Mon Sep 17 00:00:00 2001 From: LimHyunwoo <81962309+imenuuu@users.noreply.github.com> Date: Fri, 2 Feb 2024 19:01:45 +0900 Subject: [PATCH 6/6] =?UTF-8?q?refactor:=20=EC=9E=84=EC=8B=9C=20=EA=B3=B5?= =?UTF-8?q?=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cmc_be/notification/controller/NotificationController.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/example/cmc_be/notification/controller/NotificationController.kt b/src/main/kotlin/com/example/cmc_be/notification/controller/NotificationController.kt index abc0f14..095adb3 100644 --- a/src/main/kotlin/com/example/cmc_be/notification/controller/NotificationController.kt +++ b/src/main/kotlin/com/example/cmc_be/notification/controller/NotificationController.kt @@ -21,8 +21,9 @@ class NotificationController( ) { @GetMapping("/latest") @Operation(summary = "02-01 본인 기수 최신 공지 조회") - fun getThisWeekNotification(@AuthenticationPrincipal user: User): CommonResponse { - return CommonResponse.onSuccess(notificationService.getThisWeekNotification(user)) + fun getThisWeekNotification(@AuthenticationPrincipal user: User): CommonResponse> { + //return CommonResponse.onSuccess(notificationService.getThisWeekNotification(user)) + return CommonResponse.onSuccess(notificationService.getAllNotification(user.nowGeneration)) } @GetMapping("/all")