From 07dc38c994cea4583aa90ca0b4161d8c3b176bee Mon Sep 17 00:00:00 2001 From: Seokjin Jeon Date: Tue, 2 Apr 2024 15:15:21 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20refactor:=20=EC=84=9C=EB=B8=8C=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F?= =?UTF-8?q?=20=EA=B2=BD=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20(#826)=20(#827)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: 서브모듈 위치 변경 및 업데이트 * feat: 새로운 개발 환경에 맞춘 CD Github Action 수정 * fix: Dockerfile 경로 수정 * fix: Dockerfile 내부 jar 파일 경로 수정 * fix: Docker push 직접 스크립트 사용하도록 변경 * fix: Docker push 스크립트 수정 * feat: 서브 모듈 업데이트 --- .github/workflows/cd-back-dev.yml | 28 ++++++++++++---------- .gitmodules | 4 ++-- backend/Dockerfile | 4 ++++ backend/src/main/resources/application.yml | 5 ---- backend/src/main/resources/config | 1 + backend/src/main/resources/festago-config | 1 - 6 files changed, 22 insertions(+), 21 deletions(-) create mode 100644 backend/Dockerfile create mode 160000 backend/src/main/resources/config delete mode 160000 backend/src/main/resources/festago-config diff --git a/.github/workflows/cd-back-dev.yml b/.github/workflows/cd-back-dev.yml index ee3c7402c..a91a8327f 100644 --- a/.github/workflows/cd-back-dev.yml +++ b/.github/workflows/cd-back-dev.yml @@ -4,7 +4,8 @@ on: push: branches: - dev - paths: 'backend/**' + paths: + - 'backend/**' workflow_dispatch: concurrency: @@ -37,22 +38,23 @@ jobs: - name: bootJar with gradle run: ./gradlew bootJar - # 2023-11-23 기준 EC2 프리티어 사용으로 인해 DEV 환경을 PROD 환경에서 실행함 - - name: deploy use scp - uses: appleboy/scp-action@master + - name: Docker Login + uses: docker/login-action@v3.1.0 with: - host: ${{secrets.FESTAGO_PROD_IP}} - username: ${{secrets.FESTAGO_PROD_USERNAME}} - key: ${{secrets.FESTAGO_SSH_KEY}} - source: "./backend/build/libs/*.jar" - target: ${{ vars.FESTAGO_PROD_JAR_DIR }} - strip_components: 3 + username: ${{ vars.DOCKER_HUB_DEV_USERNAME }} + password: ${{ secrets.DOCKER_HUB_DEV_LOGIN_TOKEN }} + + - name: Build Docker images + run: docker build -t ${{ vars.DOCKER_DEV_TAG }} . + + - name: Push Docker images + run: docker push ${{ vars.DOCKER_DEV_TAG }} - name: run application use ssh uses: appleboy/ssh-action@master with: - host: ${{secrets.FESTAGO_PROD_IP}} - username: ${{secrets.FESTAGO_PROD_USERNAME}} - key: ${{secrets.FESTAGO_SSH_KEY}} + host: ${{ vars.FESTAGO_DEV_IP }} + username: ${{ vars.FESTAGO_DEV_USERNAME }} + key: ${{secrets.FESTAGO_DEV_SSH_KEY}} script_stop: true script: ${{ vars.FESTAGO_DEV_DEPLOY_COMMAND }} diff --git a/.gitmodules b/.gitmodules index 550533915..76d6e720b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "backend/src/main/resources/festago-config"] - path = backend/src/main/resources/festago-config +[submodule "backend/src/main/resources/config"] + path = backend/src/main/resources/config url = https://github.com/festago/festago-config.git diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 000000000..99f3e9e94 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17-jdk +ARG JAR_FILE_PATH=./build/libs/*.jar +COPY ${JAR_FILE_PATH} app.jar +ENTRYPOINT ["java", "-jar", "-Duser.timezone=Asia/Seoul", "app.jar"] diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 38c23dc60..d74c444c1 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -1,8 +1,3 @@ spring: profiles: active: local - config: - import: - - classpath:/festago-config/backend/application-dev.yml - - classpath:/festago-config/backend/application-prod.yml - - classpath:/festago-config/backend/application-infra.yml diff --git a/backend/src/main/resources/config b/backend/src/main/resources/config new file mode 160000 index 000000000..2ecee3ca4 --- /dev/null +++ b/backend/src/main/resources/config @@ -0,0 +1 @@ +Subproject commit 2ecee3ca4113d2a72111584a9f01c379906e01a4 diff --git a/backend/src/main/resources/festago-config b/backend/src/main/resources/festago-config deleted file mode 160000 index 691d66a3c..000000000 --- a/backend/src/main/resources/festago-config +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 691d66a3ca69cd811862c06138c949043b546f59