From 6998a27387a1c6ee67fd2c6d283415757eab8d3b Mon Sep 17 00:00:00 2001 From: LeeShinHeang Date: Fri, 17 Jan 2025 13:28:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EB=B9=8C=EB=93=9C=20CI=20#4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docker-image.yml | 43 ++++++++++++++++++++++++ customer-service/Dockerfile | 13 +++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/build-docker-image.yml create mode 100644 customer-service/Dockerfile diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml new file mode 100644 index 0000000..a3422a9 --- /dev/null +++ b/.github/workflows/build-docker-image.yml @@ -0,0 +1,43 @@ +name: Deploy on Docker Hub + +on: + pull_request: + branches: + - develop + +jobs: + build-docker-image: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + with: + cache-disabled: true + + - name: Docker login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and tag Docker image + run: | + cd customer-service + ./gradlew clean build -x test + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/customer-service:${{ github.sha }} . + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/customer-service:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/customer-service:latest + + - name: Push Docker image to DockerHub + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/customer-service:${{ github.sha }} + docker push ${{ secrets.DOCKERHUB_USERNAME }}/customer-service:latest diff --git a/customer-service/Dockerfile b/customer-service/Dockerfile new file mode 100644 index 0000000..200c93c --- /dev/null +++ b/customer-service/Dockerfile @@ -0,0 +1,13 @@ +FROM openjdk:17-jdk-slim + +WORKDIR /app + +COPY build/libs/customer-service-0.0.1-SNAPSHOT.jar app.jar + +ENV DB_HOST=db_host_placeholder +ENV DB_PORT=3306 +ENV DB_NAME=db_name_placeholder +ENV DB_USERNAME=db_user_placeholder +ENV DB_PASSWORD=db_password_placeholder + +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file From 4478e617295159f2edcfda2cad9b8e2811a84e09 Mon Sep 17 00:00:00 2001 From: LeeShinHeang Date: Fri, 17 Jan 2025 13:43:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=ED=9B=84=20push=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20#4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index a3422a9..9cff07c 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -1,7 +1,7 @@ name: Deploy on Docker Hub on: - pull_request: + push: branches: - develop