From 1feb3fcc99082bb7a2703ceffcd29fb6b79958de Mon Sep 17 00:00:00 2001 From: java-saeng Date: Tue, 1 Aug 2023 23:19:02 +0900 Subject: [PATCH 01/11] =?UTF-8?q?feat=20:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=B6=94=EA=B0=80=ED=95=98=EA=B3=A0=20yml=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 ++ .../src/main/resources/application.yml | 45 +------------------ .../src/main/resources/kerdy-submodule | 1 + 3 files changed, 6 insertions(+), 43 deletions(-) create mode 100644 .gitmodules create mode 160000 backend/emm-sale/src/main/resources/kerdy-submodule diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..996e4febc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "backend/emm-sale/src/main/resources/kerdy-submodule"] + path = backend/emm-sale/src/main/resources/kerdy-submodule + url = https://github.com/java-saeng/kerdy-submodule.git diff --git a/backend/emm-sale/src/main/resources/application.yml b/backend/emm-sale/src/main/resources/application.yml index e11c6020b..cc63dc0c5 100644 --- a/backend/emm-sale/src/main/resources/application.yml +++ b/backend/emm-sale/src/main/resources/application.yml @@ -1,44 +1,3 @@ spring: - datasource: - url: jdbc:mysql://localhost:3306/kerdy - username: root - password: 1234 - driver-class-name: com.mysql.cj.jdbc.Driver - sql: - init: - mode: always - jpa: - hibernate: - ddl-auto: validate - properties: - hibernate: - dialect: org.hibernate.dialect.MySQL8Dialect - format_sql: true - show-sql: true - -logging: - level: - org: - hibernate: - type: - descriptor: - sql: - BasicBinder: TRACE - -github: - client: - id: client_id - secret: client_secret - url: - access-token: access-token_url - profile: profile_url - -security: - jwt: - token: - secret-key: secret_key - expire-length: 3_600_000_000 - -firebase: - project: - id: kerdy + config: + import: classpath:kerdy-submodule/application.yml diff --git a/backend/emm-sale/src/main/resources/kerdy-submodule b/backend/emm-sale/src/main/resources/kerdy-submodule new file mode 160000 index 000000000..d22c3d8ec --- /dev/null +++ b/backend/emm-sale/src/main/resources/kerdy-submodule @@ -0,0 +1 @@ +Subproject commit d22c3d8ec1bd9eb3c4f30a9366c3fda57251a4ed From d1e86d806b349c151a127e27de425927ddc21264 Mon Sep 17 00:00:00 2001 From: java-saeng Date: Tue, 1 Aug 2023 23:29:05 +0900 Subject: [PATCH 02/11] =?UTF-8?q?feat=20:=20prod=20yml=20=EC=84=9C?= =?UTF-8?q?=EB=B8=8C=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/emm-sale/src/main/resources/kerdy-submodule | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/emm-sale/src/main/resources/kerdy-submodule b/backend/emm-sale/src/main/resources/kerdy-submodule index d22c3d8ec..729ad9b3f 160000 --- a/backend/emm-sale/src/main/resources/kerdy-submodule +++ b/backend/emm-sale/src/main/resources/kerdy-submodule @@ -1 +1 @@ -Subproject commit d22c3d8ec1bd9eb3c4f30a9366c3fda57251a4ed +Subproject commit 729ad9b3f2487cc7d44f218fd9402087fdb8c784 From f18a595394e2b107ed33ec2bebf86034210fc07d Mon Sep 17 00:00:00 2001 From: java-saeng Date: Wed, 2 Aug 2023 10:30:50 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat=20:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=EC=97=90=20firebase=20key=20json=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20=EB=B0=8F=20=EA=B2=BD=EB=A1=9C=20=EC=9E=AC=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/application/FirebaseCloudMessageClient.java | 2 +- backend/emm-sale/src/main/resources/kerdy-submodule | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/emm-sale/src/main/java/com/emmsale/notification/application/FirebaseCloudMessageClient.java b/backend/emm-sale/src/main/java/com/emmsale/notification/application/FirebaseCloudMessageClient.java index 8f2ee1588..1d82daa1b 100644 --- a/backend/emm-sale/src/main/java/com/emmsale/notification/application/FirebaseCloudMessageClient.java +++ b/backend/emm-sale/src/main/java/com/emmsale/notification/application/FirebaseCloudMessageClient.java @@ -40,7 +40,7 @@ public class FirebaseCloudMessageClient { private static final String PREFIX_ACCESS_TOKEN = "Bearer "; private static final String PREFIX_FCM_REQUEST_URL = "https://fcm.googleapis.com/v1/projects/"; private static final String POSTFIX_FCM_REQUEST_URL = "/messages:send"; - private static final String FIREBASE_KEY_PATH = "firebase-kerdy.json"; + private static final String FIREBASE_KEY_PATH = "kerdy-submodule/firebase-kerdy.json"; private static final boolean DEFAULT_VALIDATE_ONLY = false; private final ObjectMapper objectMapper; diff --git a/backend/emm-sale/src/main/resources/kerdy-submodule b/backend/emm-sale/src/main/resources/kerdy-submodule index 729ad9b3f..567e36a42 160000 --- a/backend/emm-sale/src/main/resources/kerdy-submodule +++ b/backend/emm-sale/src/main/resources/kerdy-submodule @@ -1 +1 @@ -Subproject commit 729ad9b3f2487cc7d44f218fd9402087fdb8c784 +Subproject commit 567e36a4241dc20c1a3baa3d4a3336fbbd13bfef From e5f8b863da4e0b6a0f46abcc2f37a3bfd0fba988 Mon Sep 17 00:00:00 2001 From: java-saeng Date: Wed, 2 Aug 2023 13:38:05 +0900 Subject: [PATCH 04/11] =?UTF-8?q?chore=20:=20=EB=B0=B0=ED=8F=AC=ED=95=A0?= =?UTF-8?q?=20=EC=8B=9C=20=EC=84=A0=ED=83=9D=EB=90=9C=20=EB=B8=8C=EB=9E=9C?= =?UTF-8?q?=EC=B9=98=EB=A1=9C=20=EC=B2=B4=ED=81=AC=EC=95=84=EC=9B=83?= =?UTF-8?q?=ED=95=98=EA=B2=8C=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev-deploy.yml b/.github/workflows/backend-dev-deploy.yml index ffdcd831b..ff439ef84 100644 --- a/.github/workflows/backend-dev-deploy.yml +++ b/.github/workflows/backend-dev-deploy.yml @@ -25,8 +25,11 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 steps: - - name: 백엔드 메인으로 checkout + - name: 선택된 브랜치로 checkout uses: actions/checkout@v3 + with: + token: ${{ secrets.ACTION_TOKEN }} + submodules: true - name: firebase key 생성 run: | From c244cfcda9373cf463f74a86763116b3d2c31c18 Mon Sep 17 00:00:00 2001 From: java-saeng Date: Wed, 2 Aug 2023 14:17:54 +0900 Subject: [PATCH 05/11] =?UTF-8?q?refactor=20:=20dev,=20prod,=20local(defau?= =?UTF-8?q?lt)=20config=EC=97=90=20=EB=94=B0=EB=9D=BC=EC=84=9C=20yml=20?= =?UTF-8?q?=EC=84=A4=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 - 서브 모듈 같이 수정 --- .../src/main/resources/application.yml | 64 ++++++++++++++++++- .../src/main/resources/kerdy-submodule | 2 +- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/backend/emm-sale/src/main/resources/application.yml b/backend/emm-sale/src/main/resources/application.yml index cc63dc0c5..24b5c6012 100644 --- a/backend/emm-sale/src/main/resources/application.yml +++ b/backend/emm-sale/src/main/resources/application.yml @@ -1,3 +1,65 @@ spring: + datasource: + url: jdbc:mysql://localhost:3306/kerdy + username: root + password: 1234 + driver-class-name: com.mysql.cj.jdbc.Driver + sql: + init: + mode: always + jpa: + hibernate: + ddl-auto: validate + properties: + hibernate: + dialect: org.hibernate.dialect.MySQL8Dialect + format_sql: true + show-sql: true config: - import: classpath:kerdy-submodule/application.yml + activate: + on-profile: default + +logging: + level: + org: + hibernate: + type: + descriptor: + sql: + BasicBinder: TRACE + +github: + client: + id: client_id + secret: client_secret + url: + access-token: access-token_url + profile: profile_url + +security: + jwt: + token: + secret-key: secret_key + expire-length: 3_600_000_000 + +firebase: + project: + id: kerdy + + +--- + +spring: + config: + import: classpath:kerdy-submodule/application-dev.yml + activate: + on-profile: dev + +--- + +spring: + config: + import: classpath:kerdy-submodule/application-prod.yml + activate: + on-profile: prod + diff --git a/backend/emm-sale/src/main/resources/kerdy-submodule b/backend/emm-sale/src/main/resources/kerdy-submodule index 567e36a42..cb7dbb037 160000 --- a/backend/emm-sale/src/main/resources/kerdy-submodule +++ b/backend/emm-sale/src/main/resources/kerdy-submodule @@ -1 +1 @@ -Subproject commit 567e36a4241dc20c1a3baa3d4a3336fbbd13bfef +Subproject commit cb7dbb03715c572399840e5434ef1b44f023032f From cd73d8b9ab89bac072391dd9fd92fe5bca181857 Mon Sep 17 00:00:00 2001 From: java-saeng Date: Wed, 2 Aug 2023 14:19:28 +0900 Subject: [PATCH 06/11] =?UTF-8?q?chore=20:=20firebase=20key=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 #164 --- .github/workflows/backend-dev-deploy.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/backend-dev-deploy.yml b/.github/workflows/backend-dev-deploy.yml index ff439ef84..fdc21a5ef 100644 --- a/.github/workflows/backend-dev-deploy.yml +++ b/.github/workflows/backend-dev-deploy.yml @@ -31,14 +31,6 @@ jobs: token: ${{ secrets.ACTION_TOKEN }} submodules: true - - name: firebase key 생성 - run: | - echo "${{ secrets.FIREBASE_KEY }}" > firebase-kerdy.json - - - name: firebase key 이동 - run: | - cp firebase-kerdy.json src/main/resources - - name: JDK 11로 설정 uses: actions/setup-java@v3 with: From 67493564354eaa2a61db5973e75054f4f1a676ba Mon Sep 17 00:00:00 2001 From: HyeonjaeKwon Date: Wed, 2 Aug 2023 14:38:13 +0900 Subject: [PATCH 07/11] =?UTF-8?q?chore:=20prod=20=EC=84=9C=EB=B2=84=20?= =?UTF-8?q?=EB=8F=84=EC=BB=A4=20=ED=8C=8C=EC=9D=BC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/emm-sale/Dockerfile-prod | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 backend/emm-sale/Dockerfile-prod diff --git a/backend/emm-sale/Dockerfile-prod b/backend/emm-sale/Dockerfile-prod new file mode 100644 index 000000000..26b6f6374 --- /dev/null +++ b/backend/emm-sale/Dockerfile-prod @@ -0,0 +1,4 @@ +FROM openjdk:11 as build +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} kerdy.jar +ENTRYPOINT ["java","-Dspring.profiles.active=dev","-jar","/kerdy.jar"] From 9f80bf2293bdfd02c536a19ba980ba779a268309 Mon Sep 17 00:00:00 2001 From: HyeonjaeKwon Date: Wed, 2 Aug 2023 14:38:57 +0900 Subject: [PATCH 08/11] =?UTF-8?q?chore:=20prod=20=ED=99=98=EA=B2=BD=20CICD?= =?UTF-8?q?=20workflow=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-prod-deploy.yml | 86 +++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/backend-prod-deploy.yml diff --git a/.github/workflows/backend-prod-deploy.yml b/.github/workflows/backend-prod-deploy.yml new file mode 100644 index 000000000..dcc91d652 --- /dev/null +++ b/.github/workflows/backend-prod-deploy.yml @@ -0,0 +1,86 @@ +name: Kerdy Backend Prod Server CI/CD + +on: + workflow_dispatch: + push: + branches: [ Feature/#164-DEV_PROD_YML_분리_및_서브모듈_적용 ] + +jobs: + build: + runs-on: ubuntu-22.04 + defaults: + run: + working-directory: backend/emm-sale + services: + mysql: + image: mysql:8.0.28 + env: + MYSQL_USER: user + MYSQL_PASSWORD: password + MYSQL_ROOT_PASSWORD: 1234 + MYSQL_DATABASE: kerdy + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: workflow_dispatch에서 지정한 branch로 checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.SUBMODULE_TOKEN }} + submodules: true + + - name: firebase key 생성 + run: | + echo "${{ secrets.FIREBASE_KEY }}" > firebase-kerdy.json + - name: firebase key 이동 + run: | + cp firebase-kerdy.json src/main/resources + + - name: JDK 11로 설정 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'corretto' + + - name: Gradle에 실행 권한 부여 + run: chmod +x gradlew + + - name: Actions/Caches에 Gradle 라이브러리 캐싱 + id: cache-gradle + uses: actions/cache@v3 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle- + # RestDocs의 index.html 업데이트 반영을 위해 2번 build하도록 함 + - name: gradle 빌드 + run: ./gradlew build && ./gradlew build + + - name: 도커 빌더 생성 및 부팅 + uses: docker/setup-buildx-action@v2 + + - name: 도커 허브에 로그인 + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: 도커 이미지 빌드 및 푸시 + uses: docker/build-push-action@v4 + with: + context: backend/emm-sale + file: backend/emm-sale/Dockerfile-prod + platforms: linux/arm64/v8 + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/kerdy:latest + + deploy: + needs: build + name: 배포 + runs-on: [ self-hosted, label-prod ] + steps: + - name: 도커 실행 + run: | + docker stop kerdy && docker rm kerdy && docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/kerdy + docker run -d -p 8080:8080 --name kerdy ${{ secrets.DOCKERHUB_USERNAME }}/kerdy From 0419a72b70f583c2daeb7c16492bd7b2171f399a Mon Sep 17 00:00:00 2001 From: HyeonjaeKwon Date: Wed, 2 Aug 2023 14:51:33 +0900 Subject: [PATCH 09/11] =?UTF-8?q?chore:=20=ED=99=98=EA=B2=BD=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EC=84=A4=EC=A0=95=20=ED=8C=8C=EC=9D=BC=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/emm-sale/Dockerfile-prod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/emm-sale/Dockerfile-prod b/backend/emm-sale/Dockerfile-prod index 26b6f6374..82b8139c3 100644 --- a/backend/emm-sale/Dockerfile-prod +++ b/backend/emm-sale/Dockerfile-prod @@ -1,4 +1,4 @@ FROM openjdk:11 as build ARG JAR_FILE=build/libs/*.jar COPY ${JAR_FILE} kerdy.jar -ENTRYPOINT ["java","-Dspring.profiles.active=dev","-jar","/kerdy.jar"] +ENTRYPOINT ["java","-Dspring.profiles.active=prod","-jar","/kerdy.jar"] From b15723f88038a5f6c3fcd504a46a5ea1d8741cee Mon Sep 17 00:00:00 2001 From: java-saeng <62413589+java-saeng@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:58:15 +0900 Subject: [PATCH 10/11] =?UTF-8?q?chore=20:=20token=20=ED=82=A4=20=EA=B0=92?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-dev-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-dev-deploy.yml b/.github/workflows/backend-dev-deploy.yml index fdc21a5ef..2475945ae 100644 --- a/.github/workflows/backend-dev-deploy.yml +++ b/.github/workflows/backend-dev-deploy.yml @@ -28,7 +28,7 @@ jobs: - name: 선택된 브랜치로 checkout uses: actions/checkout@v3 with: - token: ${{ secrets.ACTION_TOKEN }} + token: ${{ secrets.SUBMODULE_TOKEN }} submodules: true - name: JDK 11로 설정 From 35dc1f01ca08d592a22178e4cbed550724fbcb61 Mon Sep 17 00:00:00 2001 From: HyeonjaeKwon Date: Wed, 2 Aug 2023 15:15:02 +0900 Subject: [PATCH 11/11] =?UTF-8?q?chore:=20=ED=91=B8=EC=8B=9C=20=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-prod-deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/backend-prod-deploy.yml b/.github/workflows/backend-prod-deploy.yml index dcc91d652..2c386864f 100644 --- a/.github/workflows/backend-prod-deploy.yml +++ b/.github/workflows/backend-prod-deploy.yml @@ -2,8 +2,6 @@ name: Kerdy Backend Prod Server CI/CD on: workflow_dispatch: - push: - branches: [ Feature/#164-DEV_PROD_YML_분리_및_서브모듈_적용 ] jobs: build: