From de9aae5fd8545d12dffed80284089c9722db0aee Mon Sep 17 00:00:00 2001 From: sw-develop Date: Sun, 7 Jul 2024 23:50:46 +0900 Subject: [PATCH] =?UTF-8?q?add:=20cd=20=ED=8C=8C=EC=9D=B4=ED=94=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions/healthcheck.config | 3 + .github/workflows/cd.yaml | 56 +++++++++++++++++++ .../com/mashup/dojo/HealthController.kt | 14 +++++ deploy/Procfile | 1 + 4 files changed, 74 insertions(+) create mode 100644 .ebextensions/healthcheck.config create mode 100644 .github/workflows/cd.yaml create mode 100644 api/src/main/kotlin/com/mashup/dojo/HealthController.kt create mode 100644 deploy/Procfile diff --git a/.ebextensions/healthcheck.config b/.ebextensions/healthcheck.config new file mode 100644 index 00000000..ecc6bf53 --- /dev/null +++ b/.ebextensions/healthcheck.config @@ -0,0 +1,3 @@ +option_settings: + aws:elasticbeanstalk:application: + Application Healthcheck URL: "/health" diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 00000000..20022fa6 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,56 @@ +name: CD +on: + push: + branches: + - release/** + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - name: 소스 코드 다운로드 + uses: actions/checkout@v3 + + - name: JDK 다운로드 + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 21 + + - name: 빌드 캐싱 + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: 현재 시간 가져오기 + uses: 1466587594/get-current-time@v2 + id: current-time + with: + format: YYYY-MM-DDTHH-mm-ss + utcOffset: "+09:00" + + - name: 빌드 + run: chmod +x gradlew && ./gradlew bootJar + + - name: 배포 압축 파일 생성 + run: | + sed -i 's/{JASYPT_SECRET}/${{ secrets.JASYPT_ENCRYPTOR_PASSWORD }}/' ./deploy/Procfile + cp ./api/build/libs/api-1.0.0.jar ./deploy/application.jar + cd deploy && zip -r deploy.zip . + + - name: 배포 + uses: einaregilsson/beanstalk-deploy@v22 + with: + aws_access_key: ${{ secrets.AWS_ACCESS_KEY }} + aws_secret_key: ${{ secrets.AWS_SECRET_KEY }} + application_name: dojo-backend-eb-app + environment_name: dojo-backend-eb-env + version_label: dojo-${{ vars.GITHUB_SHA }}-${{steps.current-time.outputs.formattedTime}} + region: ap-northeast-2 + deployment_package: ./deploy/deploy.zip + wait_for_deployment: true diff --git a/api/src/main/kotlin/com/mashup/dojo/HealthController.kt b/api/src/main/kotlin/com/mashup/dojo/HealthController.kt new file mode 100644 index 00000000..7c9c7b87 --- /dev/null +++ b/api/src/main/kotlin/com/mashup/dojo/HealthController.kt @@ -0,0 +1,14 @@ +package com.mashup.dojo + +import io.swagger.v3.oas.annotations.Hidden +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +class HealthController { + @Hidden + @GetMapping("/health") + fun health(): String { + return "OK" + } +} diff --git a/deploy/Procfile b/deploy/Procfile new file mode 100644 index 00000000..87de4905 --- /dev/null +++ b/deploy/Procfile @@ -0,0 +1 @@ +web: java -jar -Duser.timezone=Asia/Seoul -Dspring.profiles.active=prod -Dserver.port=5000 -DJASYPT_ENCRYPTOR_PASSWORD={JASYPT_SECRET} ./application.jar