From 04773c1b9b92ad64fdb54aadb42939e24a2e79e2 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 02:50:40 +0900 Subject: [PATCH 1/7] =?UTF-8?q?chore=20:=20Gradle=20=EC=BA=90=EC=8B=B1=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 2dfd085b..f11805fb 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -16,17 +16,30 @@ jobs: steps: - uses: actions/checkout@v3 + + # 빌드 시간 향상을 위한 gradle caching + - name: Gradle Caching + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}" + restore-keys: | + ${{ runner.os }}-gradle- + - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - name: Grant permission run: chmod +x ./gradlew - name: Build with Gradle - run: ./gradlew bootJar + run: ./gradlew assemble - name: Docker build and push run: | From e984cbf922ac4cf906f53482ff039cae3faf28e8 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 22:17:36 +0900 Subject: [PATCH 2/7] =?UTF-8?q?fix=20:=20gradlew=20bootJar=EB=A1=9C=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=20=EB=AA=85=EB=A0=B9=EC=96=B4=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 --- .github/workflows/github-actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index f11805fb..ffcdf914 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -39,7 +39,7 @@ jobs: run: chmod +x ./gradlew - name: Build with Gradle - run: ./gradlew assemble + run: ./gradlew bootJar - name: Docker build and push run: | From f88e81dbf95a0b7ddac5a69ff31e2cb27d11d9d4 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 22:59:36 +0900 Subject: [PATCH 3/7] =?UTF-8?q?chore=20:=20docker=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=BA=90=EC=8B=9C=20=EC=A0=81=EC=9A=A9=20=EB=B0=8F=20gradle=20?= =?UTF-8?q?=EB=B9=8C=EB=93=9C=EC=99=80=20docker=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=B4=ED=94=84=EB=9D=BC=EC=9D=B8=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 54 +++++++++++++++++++++++----- Dockerfile | 10 +----- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index ffcdf914..ccbf950e 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -13,9 +13,8 @@ jobs: build: name: Build runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # 빌드 시간 향상을 위한 gradle caching - name: Gradle Caching @@ -41,14 +40,53 @@ jobs: - name: Build with Gradle run: ./gradlew bootJar - - name: Docker build and push - run: | - docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} . - docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: app-jar + path: build/libs/*.jar - deploy: + docker: needs: build + name: Docker Build + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + + - name: Download JAR Artifact + uses: actions/download-artifact@v3 + with: + name: app-jar + path: build/libs/ + + - name : Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest + platforms: linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Clean up Artifact + run: rm -rf build/libs/*.jar + + deploy: + needs: docker name: Deploy runs-on: ubuntu-latest steps: diff --git a/Dockerfile b/Dockerfile index f038e401..5892fdf1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,16 @@ # 1단계 : 빌드 환경 FROM eclipse-temurin:17-jdk-alpine AS builder - # 작업 디렉토리 설정 WORKDIR /app - # 애플리케이션 JAR 파일을 컨테이너로 복사 ARG JAR_FILE=./build/libs/*.jar COPY ${JAR_FILE} /app.jar # 2단계 : 실행 환경 FROM eclipse-temurin:17-jre-alpine - # glibc 호환성을 위한 gcompat 설치 RUN apk add --no-cache gcompat - # 빌드된 JAR 파일을 복사 COPY --from=builder /app.jar /app.jar - -# Spring 프로파일 설정 -ENV SPRING_PROFILES_ACTIVE=prod - # 애플리케이션 실행 -ENTRYPOINT ["java", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}", "-jar", "/app.jar"] +ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "/app.jar"] \ No newline at end of file From c2340faec4fa3eb7925fd4b9f84a9cbf56702c32 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 23:04:59 +0900 Subject: [PATCH 4/7] =?UTF-8?q?chore=20:=20actions/upload-artifact=20&=20d?= =?UTF-8?q?ownload-artifact=20=EB=B2=84=EC=A0=84=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index ccbf950e..c994dce6 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -41,7 +41,7 @@ jobs: run: ./gradlew bootJar - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: app-jar path: build/libs/*.jar @@ -55,7 +55,7 @@ jobs: uses: actions/checkout@v4 - name: Download JAR Artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: app-jar path: build/libs/ From 286feafb46efb3781699ec18be5ad3ebf6114b58 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 23:17:33 +0900 Subject: [PATCH 5/7] =?UTF-8?q?chore=20:=20artifact=20=EB=B3=B4=EA=B4=80?= =?UTF-8?q?=20=EA=B8=B0=EA=B0=84=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index c994dce6..067cf5c5 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -45,6 +45,7 @@ jobs: with: name: app-jar path: build/libs/*.jar + retention-days: 1 docker: needs: build From 14d2f361036a85904c772033e4e0ba5b7e6d2bc6 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 23:36:39 +0900 Subject: [PATCH 6/7] =?UTF-8?q?fix=20:=20docker=20build=20=EB=B0=8F=20push?= =?UTF-8?q?=20workflow=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 52 ++++------------------------ 1 file changed, 6 insertions(+), 46 deletions(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 067cf5c5..551be18d 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -40,54 +40,14 @@ jobs: - name: Build with Gradle run: ./gradlew bootJar - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: app-jar - path: build/libs/*.jar - retention-days: 1 - - docker: - needs: build - name: Docker Build - runs-on: ubuntu-latest - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Download JAR Artifact - uses: actions/download-artifact@v4 - with: - name: app-jar - path: build/libs/ - - - name : Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:latest - platforms: linux/amd64 - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Clean up Artifact - run: rm -rf build/libs/*.jar + - name: Docker build and push + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build --platform linux/amd64 -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} . + docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} deploy: - needs: docker + needs: build name: Deploy runs-on: ubuntu-latest steps: From 4506a4b7ba0a4c7ccd26b9d1e596e5a381487299 Mon Sep 17 00:00:00 2001 From: hyoinkang Date: Wed, 19 Feb 2025 23:57:49 +0900 Subject: [PATCH 7/7] =?UTF-8?q?chore=20:=20gradle=20daemon=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20off?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index 551be18d..d617c907 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -38,7 +38,7 @@ jobs: run: chmod +x ./gradlew - name: Build with Gradle - run: ./gradlew bootJar + run: ./gradlew bootJar --no-daemon - name: Docker build and push run: |