From 481d6ef33ae5a6fd3fa14fccbacfccf4b94650cb Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:18:12 +0900 Subject: [PATCH 01/13] =?UTF-8?q?feat=20:=20=EB=8F=84=EC=BB=A4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/notification/Dockerfile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 backend/notification/Dockerfile diff --git a/backend/notification/Dockerfile b/backend/notification/Dockerfile new file mode 100644 index 000000000..5da51791a --- /dev/null +++ b/backend/notification/Dockerfile @@ -0,0 +1,21 @@ +FROM bellsoft/liberica-openjdk-alpine:17 as build +WORKDIR /workspace/app + +# Copy Gradle wrapper and other necessary files +COPY build/libs/ . + +# Unpack the built application +RUN mkdir -p target/extracted +RUN java -Djarmode=layertools -jar *.jar extract --destination target/extracted + +FROM bellsoft/liberica-openjdk-alpine:17 +VOLUME /tmp +ARG EXTRACTED=/workspace/app/target/extracted + +# Copy over the unpacked application +COPY --from=build ${EXTRACTED}/dependencies/ ./ +COPY --from=build ${EXTRACTED}/spring-boot-loader/ ./ +COPY --from=build ${EXTRACTED}/snapshot-dependencies/ ./ +COPY --from=build ${EXTRACTED}/application/ ./ + +ENTRYPOINT ["java","-Dspring.profiles.active=dev","org.springframework.boot.loader.JarLauncher"] \ No newline at end of file From a0b7e144df2dc1adb5c7c40aa1fc7aa169075ae3 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:18:31 +0900 Subject: [PATCH 02/13] fix : jar off & version change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - jar 추가 생성 삭제 및 버전 변경 --- backend/notification/build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/notification/build.gradle b/backend/notification/build.gradle index ece1dc6e8..bc5234663 100644 --- a/backend/notification/build.gradle +++ b/backend/notification/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'site.timecapsulearchive' -version = '0.0.1-SNAPSHOT' +version = 'DEV-SNAPSHOT' java { sourceCompatibility = '17' @@ -15,6 +15,10 @@ repositories { mavenCentral() } +jar { + enabled = false +} + dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-web' From 38926a3f433b82e1423da1b03de16d2c34d9c9ff Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:19:10 +0900 Subject: [PATCH 03/13] fix : version change - core version change --- backend/core/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/core/build.gradle b/backend/core/build.gradle index 915c7dcd7..0b16df4a1 100644 --- a/backend/core/build.gradle +++ b/backend/core/build.gradle @@ -5,7 +5,7 @@ plugins { } group = 'site.timecapsulearchive' -version = '0.0.1-SNAPSHOT' +version = 'DEV-SNAPSHOT' java { sourceCompatibility = '17' From 003266a42fa46a88fa15228b80224ce9586a1fbc Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:19:35 +0900 Subject: [PATCH 04/13] fix : core ci/cd file name change --- .../{ci-cd-flow.yml => core-application-ci-cd-flow.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{ci-cd-flow.yml => core-application-ci-cd-flow.yml} (98%) diff --git a/.github/workflows/ci-cd-flow.yml b/.github/workflows/core-application-ci-cd-flow.yml similarity index 98% rename from .github/workflows/ci-cd-flow.yml rename to .github/workflows/core-application-ci-cd-flow.yml index 322411b49..4e547bc3d 100644 --- a/.github/workflows/ci-cd-flow.yml +++ b/.github/workflows/core-application-ci-cd-flow.yml @@ -34,7 +34,7 @@ jobs: defaults: run: - working-directory: ./backend/core + working-directory: ./backend/notification permissions: id-token: write From 96220ce6f6b6b45e5e5d0622f4499f3d5ab1bdb8 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:23:02 +0900 Subject: [PATCH 05/13] =?UTF-8?q?fix=20:=20=EC=95=8C=EB=A6=BC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../animation-application-ci-cd-flow.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/animation-application-ci-cd-flow.yml b/.github/workflows/animation-application-ci-cd-flow.yml index 054d862b1..3983cfee1 100644 --- a/.github/workflows/animation-application-ci-cd-flow.yml +++ b/.github/workflows/animation-application-ci-cd-flow.yml @@ -87,4 +87,18 @@ jobs: - name: Remove Github Actions IP from security group if: always() run: | - aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 \ No newline at end of file + aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 + + - uses: sarisia/actions-status-discord@v1 + if: success() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} + content: "여러분 <@384742716933668867> <@1084774841460215839> <@545902166842408960> <@1081452554149449748>\n 배포 완료했습니다!!" + title: "애니메이션 서버 배포 완료 알림" + description: "백엔드 애니메이션 개발 브랜치에 깃허브 액션으로 배포 완료" + image: ${{ secrets.EMBED_IMAGE }} + color: 0x0000ff + url: "https://github.com/tukcomCD2024/DroidBlossom/actions" + username: GitHub Actions Bot + avatar_url: ${{ secrets.AVATAR_URL }} \ No newline at end of file From c812d68c3f0a49c3c02598c60d4b3c166ac2806e Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:23:16 +0900 Subject: [PATCH 06/13] =?UTF-8?q?feat=20:=20notification=20ci/cd=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification-application-ci-cd-flow.yml | 119 ++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 .github/workflows/notification-application-ci-cd-flow.yml diff --git a/.github/workflows/notification-application-ci-cd-flow.yml b/.github/workflows/notification-application-ci-cd-flow.yml new file mode 100644 index 000000000..5cd495be6 --- /dev/null +++ b/.github/workflows/notification-application-ci-cd-flow.yml @@ -0,0 +1,119 @@ +name: ci/cd + +on: + push: + branches: + - develop_back_notification + - 'hotfix/[0-9a-zA-z]+-B-notification-#[0-9a-zA-z]+' + +jobs: + deploy-core: + name: notification application deploy + needs: formatting + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./backend/notification + + permissions: + id-token: write + contents: read + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + token: ${{ secrets.CI_PAT }} + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'liberica' + cache: gradle + + - name: grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: build gradle + run: ./gradlew clean build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + aws-region: ${{ secrets.AWS_REGION }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_ECR_NOTIFICATION_REPOSITORY_NAME }} + tags: | + type=raw,value=latest + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ./backend/core + platforms: linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + provenance: false + + - name: Get Github action IP + id: ip + uses: haythem/public-ip@v1.3 + + - name: Add Github Actions IP to Security group + run: | + aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 + + - name: Connect ec2 and Run Docker Container + uses: appleboy/ssh-action@v0.1.6 + env: + AWS_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + with: + host: ${{ secrets.SSH_NOTIFICATION_HOST }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_CORE_PRIVATE_KEY }} + port: ${{ secrets.SSH_PORT }} + script: | + docker ps -q --filter "name=notification" | xargs -r docker stop + docker ps -aq --filter "name=notification" | xargs -r docker rm + aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com + docker pull ${{ steps.meta.outputs.tags }} + docker run -d -p 8080:8080 --name core --network test_backend ${{ steps.meta.outputs.tags }} + + - name: Remove Github Actions IP from security group + if: always() + run: | + aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_CORE_SG_ID }} --group-name ${{secrets.AWS_EC2_CORE_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 + + - uses: sarisia/actions-status-discord@v1 + if: success() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} + content: "여러분 <@384742716933668867> <@1084774841460215839> <@545902166842408960> <@1081452554149449748>\n 배포 완료했습니다!!" + title: "알림 서버 배포 완료 알림" + description: "백엔드 알림 개발 브랜치에 깃허브 액션으로 배포 완료" + image: ${{ secrets.EMBED_IMAGE }} + color: 0x0000ff + url: "https://github.com/tukcomCD2024/DroidBlossom/actions" + username: GitHub Actions Bot + avatar_url: ${{ secrets.AVATAR_URL }} \ No newline at end of file From 45c38c32977ce634a605641781f5073653084b42 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:38:36 +0900 Subject: [PATCH 07/13] =?UTF-8?q?fix=20:=20name=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/notification-application-ci-cd-flow.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/notification-application-ci-cd-flow.yml b/.github/workflows/notification-application-ci-cd-flow.yml index 5cd495be6..5239decb3 100644 --- a/.github/workflows/notification-application-ci-cd-flow.yml +++ b/.github/workflows/notification-application-ci-cd-flow.yml @@ -7,9 +7,8 @@ on: - 'hotfix/[0-9a-zA-z]+-B-notification-#[0-9a-zA-z]+' jobs: - deploy-core: + deploy-notification: name: notification application deploy - needs: formatting if: ${{ github.event_name == 'push' }} runs-on: ubuntu-latest From db7d2b097ec97e13d475b7bbd0cd472c6e03cf06 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:45:08 +0900 Subject: [PATCH 08/13] =?UTF-8?q?fix=20:=20=EC=98=A4=ED=83=80=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 --- .github/workflows/notification-application-ci-cd-flow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notification-application-ci-cd-flow.yml b/.github/workflows/notification-application-ci-cd-flow.yml index 5239decb3..81ff8be5f 100644 --- a/.github/workflows/notification-application-ci-cd-flow.yml +++ b/.github/workflows/notification-application-ci-cd-flow.yml @@ -101,7 +101,7 @@ jobs: - name: Remove Github Actions IP from security group if: always() run: | - aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_CORE_SG_ID }} --group-name ${{secrets.AWS_EC2_CORE_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 + aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_NOTIFICATION_SG_ID }} --group-name ${{secrets.AWS_EC2_NOTIFICATION_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 - uses: sarisia/actions-status-discord@v1 if: success() From 952100c0519e106306d49cb406124a6d4bf55706 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:54:50 +0900 Subject: [PATCH 09/13] =?UTF-8?q?fix=20:=20=ED=86=B5=ED=95=A9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=82=AD=EC=A0=9C=20&=20submodule=20updat?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/notification/src/main/resources/config | 2 +- .../notification/NotificationApplicationTests.java | 13 ------------- 2 files changed, 1 insertion(+), 14 deletions(-) delete mode 100644 backend/notification/src/test/java/site/timecapsulearchive/notification/NotificationApplicationTests.java diff --git a/backend/notification/src/main/resources/config b/backend/notification/src/main/resources/config index 96cb0d36e..5836bab13 160000 --- a/backend/notification/src/main/resources/config +++ b/backend/notification/src/main/resources/config @@ -1 +1 @@ -Subproject commit 96cb0d36eb0a46237595f1a52e2c107bd8e877e1 +Subproject commit 5836bab13bb0f608eb7f8ec185cbd7091f12de8d diff --git a/backend/notification/src/test/java/site/timecapsulearchive/notification/NotificationApplicationTests.java b/backend/notification/src/test/java/site/timecapsulearchive/notification/NotificationApplicationTests.java deleted file mode 100644 index 1f1b16c76..000000000 --- a/backend/notification/src/test/java/site/timecapsulearchive/notification/NotificationApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package site.timecapsulearchive.notification; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class NotificationApplicationTests { - - @Test - void contextLoads() { - } - -} From 94c4b137561f9abf4a7ea5eb28f282915594b69d Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 21:59:43 +0900 Subject: [PATCH 10/13] =?UTF-8?q?fix=20:=20=EC=98=A4=ED=83=80=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 --- .github/workflows/core-application-ci-cd-flow.yml | 2 +- .github/workflows/notification-application-ci-cd-flow.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/core-application-ci-cd-flow.yml b/.github/workflows/core-application-ci-cd-flow.yml index 4e547bc3d..322411b49 100644 --- a/.github/workflows/core-application-ci-cd-flow.yml +++ b/.github/workflows/core-application-ci-cd-flow.yml @@ -34,7 +34,7 @@ jobs: defaults: run: - working-directory: ./backend/notification + working-directory: ./backend/core permissions: id-token: write diff --git a/.github/workflows/notification-application-ci-cd-flow.yml b/.github/workflows/notification-application-ci-cd-flow.yml index 81ff8be5f..d3afaf1c3 100644 --- a/.github/workflows/notification-application-ci-cd-flow.yml +++ b/.github/workflows/notification-application-ci-cd-flow.yml @@ -68,7 +68,7 @@ jobs: - name: Build and push uses: docker/build-push-action@v5 with: - context: ./backend/core + context: ./backend/notification platforms: linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} From 9737c48aa9223707aacd037f6c298666696593f0 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 22:13:37 +0900 Subject: [PATCH 11/13] =?UTF-8?q?fix=20:=20=EC=98=A4=ED=83=80=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 --- .github/workflows/notification-application-ci-cd-flow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notification-application-ci-cd-flow.yml b/.github/workflows/notification-application-ci-cd-flow.yml index d3afaf1c3..4f0ff09c4 100644 --- a/.github/workflows/notification-application-ci-cd-flow.yml +++ b/.github/workflows/notification-application-ci-cd-flow.yml @@ -96,7 +96,7 @@ jobs: docker ps -aq --filter "name=notification" | xargs -r docker rm aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com docker pull ${{ steps.meta.outputs.tags }} - docker run -d -p 8080:8080 --name core --network test_backend ${{ steps.meta.outputs.tags }} + docker run -d -p 8080:8080 --name notification --network test_backend ${{ steps.meta.outputs.tags }} - name: Remove Github Actions IP from security group if: always() From 7990f1279082583615254cd0dff59d2e1ec33175 Mon Sep 17 00:00:00 2001 From: hong seokho Date: Sun, 25 Feb 2024 23:08:50 +0900 Subject: [PATCH 12/13] =?UTF-8?q?feat=20:=20valid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/CapsuleSkinNotificationSendRequest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/notification/src/main/java/site/timecapsulearchive/notification/data/request/CapsuleSkinNotificationSendRequest.java b/backend/notification/src/main/java/site/timecapsulearchive/notification/data/request/CapsuleSkinNotificationSendRequest.java index fd58bc40c..419df9622 100644 --- a/backend/notification/src/main/java/site/timecapsulearchive/notification/data/request/CapsuleSkinNotificationSendRequest.java +++ b/backend/notification/src/main/java/site/timecapsulearchive/notification/data/request/CapsuleSkinNotificationSendRequest.java @@ -1,11 +1,23 @@ package site.timecapsulearchive.notification.data.request; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + public record CapsuleSkinNotificationSendRequest( + @NotNull Long memberId, + + @NotBlank String skinName, + + @NotBlank String title, + + @NotBlank String text, + + @NotBlank String skinUrl ) { From 7395b905091419a6d06aae04984a3a8a7b3b5ef4 Mon Sep 17 00:00:00 2001 From: GaBaljaintheroom Date: Tue, 27 Feb 2024 14:50:53 +0900 Subject: [PATCH 13/13] =?UTF-8?q?feat=20:=20=EC=84=B8=EB=B6=80=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EC=A1=B0=ED=9A=8C=20=EC=BF=BC=EB=A6=AC=20null=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/capsule/repository/CapsuleQueryRepository.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/repository/CapsuleQueryRepository.java b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/repository/CapsuleQueryRepository.java index df3e83c76..a78f16d9f 100644 --- a/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/repository/CapsuleQueryRepository.java +++ b/backend/core/src/main/java/site/timecapsulearchive/core/domain/capsule/repository/CapsuleQueryRepository.java @@ -158,7 +158,10 @@ public Optional findSecretCapsuleDetailDtosByMemberIdAnd ) .fetchFirst(); - return Optional.ofNullable(detailDto); + if (detailDto.capsuleId() == null) { + return Optional.empty(); + } + return Optional.of(detailDto); } private StringExpression groupConcatDistinct(final StringExpression expression) {