From 00c6dbcf021a8c31e330cc165e0fe8e84b5b050a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB=E1=84=90=E1=85=A2=20=E1=84=8E?= =?UTF-8?q?=E1=85=AC?= Date: Mon, 24 Feb 2025 11:06:10 +0900 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20plain=20jar=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=20=EB=B9=84=ED=99=9C=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index 999de6c..aefcd66 100644 --- a/build.gradle +++ b/build.gradle @@ -60,3 +60,5 @@ dependencies { tasks.named('test') { useJUnitPlatform() } + +jar.enabled = true \ No newline at end of file From f6c2f8d2dd92ddb1d89e3573b015b1ab4bbfe42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB=E1=84=90=E1=85=A2=20=E1=84=8E?= =?UTF-8?q?=E1=85=AC?= Date: Mon, 24 Feb 2025 11:07:04 +0900 Subject: [PATCH 2/5] =?UTF-8?q?chore:=20Dockerfile=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b658e66 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17 +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file From 1f1228479632aa84df056a7476b28a832d238da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB=E1=84=90=E1=85=A2=20=E1=84=8E?= =?UTF-8?q?=E1=85=AC?= Date: Mon, 24 Feb 2025 11:08:51 +0900 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20docker=20compose=20=ED=8C=8C?= =?UTF-8?q?=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 --- docker-compose.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c22fa0c --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: "3.8" + +services: + backend: + image: ${IMAGE_FULL_URL} + container_name: ${DOCKERHUB_IMAGE_NAME} + restart: always + network_mode: host + environment: + - TZ=Asia/Seoul + env_file: + - .env + redis: + image: "redis:alpine" + container_name: redis + ports: + - "6379:6379" + network_mode: host + environment: + - TZ=Asia/Seoul \ No newline at end of file From c33e47da814ad00b0e8fe0ab8f7fd9dbfb53e6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB=E1=84=90=E1=85=A2=20=E1=84=8E?= =?UTF-8?q?=E1=85=AC?= Date: Mon, 24 Feb 2025 11:28:54 +0900 Subject: [PATCH 4/5] =?UTF-8?q?chore:=20cd=20workflow=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/develop_build_deploy.yml | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/develop_build_deploy.yml diff --git a/.github/workflows/develop_build_deploy.yml b/.github/workflows/develop_build_deploy.yml new file mode 100644 index 0000000..85c12b0 --- /dev/null +++ b/.github/workflows/develop_build_deploy.yml @@ -0,0 +1,75 @@ +name: Build and Deploy to Develop + +on: + push: + branches: + - develop + +env: + DOCKERHUB_USERNAME: ht3064 + DOCKERHUB_IMAGE_NAME: syncfit-server + +jobs: + build-deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + - name: Build with Gradle + run: ./gradlew clean build -x test + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ env.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Extract metadata for Docker + id: metadata + uses: docker/metadata-action@v4 + with: + images: ${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_IMAGE_NAME }} + tags: | + type=sha,prefix= + + - name: Build and Push Docker image + uses: docker/build-push-action@v4.1.1 + with: + context: . + push: true + tags: ${{ steps.metadata.outputs.tags }} + + - name: Copy docker-compose.yml to EC2 + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + source: docker-compose.yml + target: /home/ubuntu/ + + - name: Deploy to EC2 + uses: appleboy/ssh-action@master + env: + IMAGE_FULL_URL: ${{ steps.metadata.outputs.tags }} + DOCKERHUB_IMAGE_NAME: ${{ env.DOCKERHUB_IMAGE_NAME }} + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USERNAME }} + key: ${{ secrets.EC2_SSH_KEY }} + envs: IMAGE_FULL_URL, DOCKERHUB_IMAGE_NAME + script: | + echo "${{ secrets.DOCKERHUB_ACCESS_TOKEN }}" | docker login -u "${{ env.DOCKERHUB_USERNAME }}" --password-stdin + docker compose up -d + docker image prune -a -f \ No newline at end of file From 34e96288e402ef1506e45601d497f4c7bd5d89b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB=E1=84=90=E1=85=A2=20=E1=84=8E?= =?UTF-8?q?=E1=85=AC?= Date: Mon, 24 Feb 2025 11:34:36 +0900 Subject: [PATCH 5/5] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=8A=B8=EB=A6=AC=EA=B1=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/develop_build_deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/develop_build_deploy.yml b/.github/workflows/develop_build_deploy.yml index 85c12b0..4df4fc6 100644 --- a/.github/workflows/develop_build_deploy.yml +++ b/.github/workflows/develop_build_deploy.yml @@ -1,6 +1,9 @@ name: Build and Deploy to Develop on: + pull_request: + branches: + - develop push: branches: - develop