From d100714412ed3d090cd3d8e0f87c9de801854c16 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 23 Apr 2024 20:39:09 +0900 Subject: [PATCH 01/31] =?UTF-8?q?=EB=AC=B4=EC=A4=91=EB=8B=A8=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 21a46197..19571b1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Build and Deploy to EC2 on: push: - branches: [ "production" ] + branches: [ "production", "main" ] pull_request: branches: [ "production" ] From e1ed74f0f6ec914a197709e61a449bf4782b34e6 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 23 Apr 2024 20:40:38 +0900 Subject: [PATCH 02/31] =?UTF-8?q?=EB=AC=B4=EC=A4=91=EB=8B=A8=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 19571b1f..1f31497a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,7 @@ on: push: branches: [ "production", "main" ] pull_request: - branches: [ "production" ] + branches: [ "production", "main" ] env: AWS_REGION: ap-northeast-2 From 35e366fe64b2cd70d7a77e278820a696ca05bc85 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 13:33:55 +0900 Subject: [PATCH 03/31] =?UTF-8?q?feat:=20main.yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1f31497a..67bded53 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,32 +51,36 @@ jobs: echo "${{ secrets.APPLICATION_TEST }}" > ./application.yml echo "${{ secrets.TEST }}" > ./application-test.yml - - name: Grant execute permission for gradlew run: chmod +x ./gradlew shell: bash - - name: Build with Gradle # and Test run: ./gradlew clean build -x test #./gradlew build test - - name: Make zip file run: zip -r ./$GITHUB_SHA.zip . shell: bash + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Deliver to AWS S3 (AWS credential 설정) + - name: Access to AWS uses: aws-actions/configure-aws-credentials@v1 with: aws-region: ${{ env.AWS_REGION }} aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }} aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }} - - + # docker build -t devrank/backend-api:latest -f Dockerfile . --platform linux/x86_64 + # docker push devrank/backend-api:latest - name: Upload to S3 run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip - - - name: Code Deploy (EC2에 배포) + - name: Code Deploy run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip From 8e3d3c5b52a2537e13c353f25aaf748dc456ca33 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 13:52:52 +0900 Subject: [PATCH 04/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 46 +++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 67bded53..9b50a1de 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,15 +2,17 @@ name: Build and Deploy to EC2 on: push: - branches: [ "production", "main" ] + branches: [ "production", "main", "feat/173-docker-deploy" ] pull_request: branches: [ "production", "main" ] + env: AWS_REGION: ap-northeast-2 AWS_S3_BUCKET: gitget-bucket-hey AWS_CODE_DEPLOY_APPLICATION: GitGet-Application-HEY AWS_CODE_DEPLOY_GROUP: GitGet-CICD-group-hey + DOCKER_HUB_REPOSITORY: geniusgitget/gitget jobs: deploy: @@ -62,6 +64,15 @@ jobs: run: zip -r ./$GITHUB_SHA.zip . shell: bash + - name: Docker meta + id: docker_meta + uses: crazy-max/ghaction-docker-meta@v1 + with: + images: ${{ DOCKER_HUB_REPOSITORY }} + tag-semver: | + {{version}} + {{major}}.{{minor}} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -69,18 +80,27 @@ jobs: uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Access to AWS - uses: aws-actions/configure-aws-credentials@v1 + - name: Docker Image Build nad Push + uses: docker/build-push-action@v2 with: - aws-region: ${{ env.AWS_REGION }} - aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }} - aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }} - # docker build -t devrank/backend-api:latest -f Dockerfile . --platform linux/x86_64 - # docker push devrank/backend-api:latest - - name: Upload to S3 - run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip + context: . + file: ./Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} - - name: Code Deploy - run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip +# - name: Access to AWS +# uses: aws-actions/configure-aws-credentials@v1 +# with: +# aws-region: ${{ env.AWS_REGION }} +# aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }} +# aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }} +# +# - name: Upload to S3 +# run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip +# +# - name: Code Deploy +# run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip From 2e3884d2f1b01ec3eb82215abd9a0d318e318a70 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 13:54:25 +0900 Subject: [PATCH 05/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b50a1de..b70d6edb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ env: AWS_S3_BUCKET: gitget-bucket-hey AWS_CODE_DEPLOY_APPLICATION: GitGet-Application-HEY AWS_CODE_DEPLOY_GROUP: GitGet-CICD-group-hey - DOCKER_HUB_REPOSITORY: geniusgitget/gitget + DOCKER_HUB_REPOSITORY: jobs: deploy: @@ -68,7 +68,7 @@ jobs: id: docker_meta uses: crazy-max/ghaction-docker-meta@v1 with: - images: ${{ DOCKER_HUB_REPOSITORY }} + images: ${{ env.DOCKER_HUB_REPOSITORY }} tag-semver: | {{version}} {{major}}.{{minor}} From 3f3cd042c75ab87f7f19a2fce32812754a6e6858 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 13:58:08 +0900 Subject: [PATCH 06/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b70d6edb..bd083185 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,7 @@ env: AWS_S3_BUCKET: gitget-bucket-hey AWS_CODE_DEPLOY_APPLICATION: GitGet-Application-HEY AWS_CODE_DEPLOY_GROUP: GitGet-CICD-group-hey - DOCKER_HUB_REPOSITORY: + DOCKER_HUB_REPOSITORY: geniusgitget/gitget jobs: deploy: From bbdd73fb04be71ee8f5808fd30591cb55e8a96d7 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:04:16 +0900 Subject: [PATCH 07/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- Dockerfile | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd083185..dc036443 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -82,7 +82,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Docker Image Build nad Push + - name: Docker Image Build and Push uses: docker/build-push-action@v2 with: context: . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..99ccec4d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# Start with a base image containing Java runtime. +FROM java:17 + +# The application's jar file. +ARG JAR_FILE=./build/libs + +# Add the application's jar to the container. +ADD ${JAR_FILE}/gitget-0.0.1-SNAPSHOT.jar app.jar + +# Run the jar file. +ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file From 3950f49093fc163542fc46deb40abe3e0f44a69f Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:07:59 +0900 Subject: [PATCH 08/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 99ccec4d..0abb8ad7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Start with a base image containing Java runtime. -FROM java:17 +FROM openjdk:17 # The application's jar file. ARG JAR_FILE=./build/libs From 7497319ed663a198ded43a2c1409a7c3c36aee41 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:13:36 +0900 Subject: [PATCH 09/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 0abb8ad7..925337c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:17 # The application's jar file. -ARG JAR_FILE=./build/libs +ARG JAR_FILE= build/libs # Add the application's jar to the container. ADD ${JAR_FILE}/gitget-0.0.1-SNAPSHOT.jar app.jar From b64a8bc3311c46a0d49cbba95f39b8dc46b476d6 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:20:41 +0900 Subject: [PATCH 10/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 925337c0..7347f6a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ # Start with a base image containing Java runtime. -FROM openjdk:17 +FROM openjdk:17-jdk # The application's jar file. -ARG JAR_FILE= build/libs +ARG JAR_FILE=build/libs/gitget-0.0.1-SNAPSHOT.jar # Add the application's jar to the container. -ADD ${JAR_FILE}/gitget-0.0.1-SNAPSHOT.jar app.jar +COPY ${JAR_FILE} app.jar # Run the jar file. -ENTRYPOINT ["java", "-jar", "app.jar"] \ No newline at end of file +CMD ["java", "-jar", "app.jar"] \ No newline at end of file From 78c36c26f765435c9997d0cd0a0db09f87626a56 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:38:35 +0900 Subject: [PATCH 11/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dc036443..fe7157d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -74,10 +74,10 @@ jobs: {{major}}.{{minor}} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v1 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} From 8355b7dc7f54afc0cceba23ae7988ff1c3a3961f Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:42:17 +0900 Subject: [PATCH 12/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7347f6a3..4f02008d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:17-jdk # The application's jar file. -ARG JAR_FILE=build/libs/gitget-0.0.1-SNAPSHOT.jar +ARG JAR_FILE=./build/libs/gitget-0.0.1-SNAPSHOT.jar # Add the application's jar to the container. COPY ${JAR_FILE} app.jar From 22e6cfabb683b4d54abd8a9d4e98bff747d1fa97 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 14:58:39 +0900 Subject: [PATCH 13/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4f02008d..39789e8d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:17-jdk # The application's jar file. -ARG JAR_FILE=./build/libs/gitget-0.0.1-SNAPSHOT.jar +ARG JAR_FILE=./TeamTheGenius_Server/build/libs/gitget-0.0.1-SNAPSHOT.jar # Add the application's jar to the container. COPY ${JAR_FILE} app.jar From 8791c056a4334a4c65afef014b42cbb3218e88b1 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 15:16:04 +0900 Subject: [PATCH 14/31] =?UTF-8?q?feat:=20docker=20build=20and=20push=20scr?= =?UTF-8?q?ipt=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe7157d6..68a7ef9d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,12 +57,12 @@ jobs: run: chmod +x ./gradlew shell: bash - - name: Build with Gradle # and Test - run: ./gradlew clean build -x test #./gradlew build test + - name: Build with Gradle + run: ./gradlew clean build - - name: Make zip file - run: zip -r ./$GITHUB_SHA.zip . - shell: bash + # - name: Make zip file + # run: zip -r ./$GITHUB_SHA.zip . + # shell: bash - name: Docker meta id: docker_meta From b62c9b75dc6f7cd195155b79508289d6b59b131f Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 17:07:00 +0900 Subject: [PATCH 15/31] git actions & docker TEST --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 39789e8d..4f02008d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM openjdk:17-jdk # The application's jar file. -ARG JAR_FILE=./TeamTheGenius_Server/build/libs/gitget-0.0.1-SNAPSHOT.jar +ARG JAR_FILE=./build/libs/gitget-0.0.1-SNAPSHOT.jar # Add the application's jar to the container. COPY ${JAR_FILE} app.jar From 521e6fd1ee373088007d2a9ed75f10d962ab139b Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 17:18:19 +0900 Subject: [PATCH 16/31] git actions & docker TEST --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4f02008d..95e32324 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,10 +2,10 @@ FROM openjdk:17-jdk # The application's jar file. -ARG JAR_FILE=./build/libs/gitget-0.0.1-SNAPSHOT.jar +ARG JAR_FILE=./build/libs/GitGetApplication.jar # Add the application's jar to the container. -COPY ${JAR_FILE} app.jar +COPY ${JAR_FILE} App.jar # Run the jar file. -CMD ["java", "-jar", "app.jar"] \ No newline at end of file +CMD ["java", "-jar", "App.jar"] \ No newline at end of file From d634b51355504730492f8a7fe6d2f44b412e2901 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 14 May 2024 18:08:31 +0900 Subject: [PATCH 17/31] git actions & docker TEST --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 68a7ef9d..c8fb8e60 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,9 +98,9 @@ jobs: # aws-region: ${{ env.AWS_REGION }} # aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }} # aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }} -# + # - name: Upload to S3 # run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip -# + # - name: Code Deploy # run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip From a5d7770791c4122d2cd5181cac0d1715024fc3cf Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Wed, 15 May 2024 22:07:17 +0900 Subject: [PATCH 18/31] self-hosted runners & docker compose test --- .github/workflows/main.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8fb8e60..3c73fa67 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ env: DOCKER_HUB_REPOSITORY: geniusgitget/gitget jobs: - deploy: + backend-docker-build-and-push: runs-on: ubuntu-latest permissions: contents: read @@ -92,6 +92,16 @@ jobs: tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} + backend-docker-pull-and-run: + runs-on: [ self-hosted, dev ] + if: ${{ needs.backend-docker-build-and-push.result == 'success' }} + needs: [ backend-docker-build-and-push ] + steps: + - name: Execute Deploy Script + run: | + sh /home/ubuntu/deploy.sh + + # - name: Access to AWS # uses: aws-actions/configure-aws-credentials@v1 # with: From ad4a392fe46d928db46ce118eb8e75f4b61ea197 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Thu, 16 May 2024 19:41:35 +0900 Subject: [PATCH 19/31] self-hosted runners & docker compose test --- .github/workflows/main.yml | 12 +----------- scripts/health.sh | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3c73fa67..14c50a36 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -64,15 +64,6 @@ jobs: # run: zip -r ./$GITHUB_SHA.zip . # shell: bash - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v1 - with: - images: ${{ env.DOCKER_HUB_REPOSITORY }} - tag-semver: | - {{version}} - {{major}}.{{minor}} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 @@ -89,8 +80,7 @@ jobs: file: ./Dockerfile platforms: linux/amd64 push: true - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} + tags: ${{ env.DOCKER_HUB_REPOSITORY }}:latest backend-docker-pull-and-run: runs-on: [ self-hosted, dev ] diff --git a/scripts/health.sh b/scripts/health.sh index baa66cc7..e9539eb8 100644 --- a/scripts/health.sh +++ b/scripts/health.sh @@ -16,7 +16,6 @@ else exit 1 fi - echo "> Start health check of WAS at http://localhost:${TARGET_PORT}/api/auth/health-check ..." for RETRY_COUNT in 1 2 3 4 5 6 7 8 9 10 From cc7bbf3e13bebbbce51e9e279cd8e061def9ce2b Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Thu, 16 May 2024 21:28:23 +0900 Subject: [PATCH 20/31] self-hosted runners & docker compose test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14c50a36..2f462515 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,7 +71,7 @@ jobs: uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Docker Image Build and Push uses: docker/build-push-action@v2 From 6deef6b04c5b5bbb9bb3368120d1e19b74becbf1 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Thu, 16 May 2024 21:33:14 +0900 Subject: [PATCH 21/31] self-hosted runners & docker compose test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2f462515..14c50a36 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -71,7 +71,7 @@ jobs: uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Docker Image Build and Push uses: docker/build-push-action@v2 From a84856f7c87c8929223124c702f2332649b21332 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Fri, 17 May 2024 11:53:20 +0900 Subject: [PATCH 22/31] docker compose & nginx test --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14c50a36..96183505 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -87,7 +87,7 @@ jobs: if: ${{ needs.backend-docker-build-and-push.result == 'success' }} needs: [ backend-docker-build-and-push ] steps: - - name: Execute Deploy Script + - name: Execute Deploy Script ! run: | sh /home/ubuntu/deploy.sh From c3e8019031a9bed4cf53f752b4307a37f6186e04 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 27 May 2024 19:25:30 +0900 Subject: [PATCH 23/31] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 60 +++++++++----------------------------- appspec.yml | 28 ------------------ 2 files changed, 13 insertions(+), 75 deletions(-) delete mode 100644 appspec.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96183505..424955cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,13 +7,6 @@ on: branches: [ "production", "main" ] -env: - AWS_REGION: ap-northeast-2 - AWS_S3_BUCKET: gitget-bucket-hey - AWS_CODE_DEPLOY_APPLICATION: GitGet-Application-HEY - AWS_CODE_DEPLOY_GROUP: GitGet-CICD-group-hey - DOCKER_HUB_REPOSITORY: geniusgitget/gitget - jobs: backend-docker-build-and-push: runs-on: ubuntu-latest @@ -21,7 +14,6 @@ jobs: contents: read packages: write steps: - # Actions - name: Checkout uses: actions/checkout@v4 @@ -60,47 +52,21 @@ jobs: - name: Build with Gradle run: ./gradlew clean build - # - name: Make zip file - # run: zip -r ./$GITHUB_SHA.zip . - # shell: bash - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to Docker Hub - uses: docker/login-action@v1 + - name: docker login + uses: docker /login-action@v2 with: username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker Image Build and Push - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64 - push: true - tags: ${{ env.DOCKER_HUB_REPOSITORY }}:latest - - backend-docker-pull-and-run: - runs-on: [ self-hosted, dev ] - if: ${{ needs.backend-docker-build-and-push.result == 'success' }} - needs: [ backend-docker-build-and-push ] - steps: - - name: Execute Deploy Script ! - run: | - sh /home/ubuntu/deploy.sh + password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: docker image build + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/gitget-application . -# - name: Access to AWS -# uses: aws-actions/configure-aws-credentials@v1 -# with: -# aws-region: ${{ env.AWS_REGION }} -# aws-access-key-id: ${{ secrets.CICD_ACCESS_KEY_HEY }} -# aws-secret-access-key: ${{ secrets.CICD_SECRET_KEY_HEY }} + - name: dockerhub push + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/gitget-application -# - name: Upload to S3 -# run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$AWS_S3_BUCKET/$GITHUB_SHA.zip - -# - name: Code Deploy -# run: aws deploy create-deployment --application-name GitGet-Application-HEY --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name GitGet-CICD-group-hey --s3-location bucket=$AWS_S3_BUCKET,key=$GITHUB_SHA.zip,bundleType=zip + run-docker-image-on-ec2: + needs: build-docker-image + runs-on: self-hosted + steps: + - name: execute deploy.sh + run: sh /home/ec2-user/deploy.sh \ No newline at end of file diff --git a/appspec.yml b/appspec.yml deleted file mode 100644 index 3f9d6147..00000000 --- a/appspec.yml +++ /dev/null @@ -1,28 +0,0 @@ -version: 0.0 # CodeDeploy Version. - -os: linux # 배포할 서버의 운영체제 - -files: - - source: / # CodeDeploy에서 전달해 준 파일 중 destination으로 이동시킬 대상을 지정 (루트 경로 : 전체 파일) - destination: /home/ubuntu/app # source에서 지정된 파일을 받을 위치 - overwrite: yes # 기존 파일들을 덮어 쓰기 - -# CodeDeploy에서 EC2로 넘겨준 파일들을 모두 ec2-user 권한 부여. -permissions: - - object: / - pattern: "**" - owner: ubuntu - group: ubuntu - -# CodeDeploy 배포 단계에서 실행할 명령어를 지정 (차례대로 스크립트들이 실행) -hooks: - ApplicationStart: - - location: scripts/run_new_was.sh - timeout: 180 - runas: ubuntu - - location: scripts/health.sh - timeout: 180 - runas: ubuntu - - location: scripts/switch.sh - timeout: 180 - runas: ubuntu From ddcbcb6050caba9623aa397b2cca7c7214ee4385 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 27 May 2024 19:36:30 +0900 Subject: [PATCH 24/31] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 424955cc..82b9e5ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,13 +6,9 @@ on: pull_request: branches: [ "production", "main" ] - jobs: - backend-docker-build-and-push: + build-docker-image: runs-on: ubuntu-latest - permissions: - contents: read - packages: write steps: - name: Checkout uses: actions/checkout@v4 From 7014ef9e5d3ec238e58bed30660c7fe19cee4bad Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 27 May 2024 19:44:08 +0900 Subject: [PATCH 25/31] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 82b9e5ae..6c381445 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,7 @@ jobs: shell: bash - name: Build with Gradle - run: ./gradlew clean build + run: ./gradlew clean build -x test - name: docker login uses: docker /login-action@v2 From da2c14f2d5e8f71d69ebb91f5b9456aa3270ba59 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 27 May 2024 20:38:47 +0900 Subject: [PATCH 26/31] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6c381445..03b18358 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,6 @@ jobs: java-version: '17' distribution: 'temurin' - # 프로젝트 내 yml 파일 실행 - name: make application.yml run: | mkdir -p ./src/main/resources From 883b5e1faefff960166b131e8ae24326e099c5ff Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Mon, 27 May 2024 21:45:00 +0900 Subject: [PATCH 27/31] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genius/gitget/global/security/config/SecurityConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java b/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java index b189ab5c..b61daa1f 100644 --- a/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java +++ b/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java @@ -27,7 +27,8 @@ @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfig { - public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/**", "/login", "/favicon.ico"}; + public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/health-check", "/login", + "/favicon.ico"}; private static final String PERMITTED_ROLES[] = {"USER", "ADMIN"}; private final CustomCorsConfigurationSource customCorsConfigurationSource; private final CustomOAuth2UserService customOAuthService; From be8eb0c7ee2833dbce9bfdee239b592ddac26dc5 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 28 May 2024 11:00:16 +0900 Subject: [PATCH 28/31] =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../genius/gitget/global/security/config/SecurityConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java b/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java index b61daa1f..2bd56770 100644 --- a/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java +++ b/src/main/java/com/genius/gitget/global/security/config/SecurityConfig.java @@ -27,7 +27,7 @@ @RequiredArgsConstructor @EnableWebSecurity public class SecurityConfig { - public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/health-check", "/login", + public static final String PERMITTED_URI[] = {"/v3/**", "/swagger-ui/**", "/api/auth/**", "/login", "/favicon.ico"}; private static final String PERMITTED_ROLES[] = {"USER", "ADMIN"}; private final CustomCorsConfigurationSource customCorsConfigurationSource; From 27f5f50bfa2c7c361777018c850fc62de1630919 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 28 May 2024 11:15:56 +0900 Subject: [PATCH 29/31] =?UTF-8?q?feat:=20=EB=AC=B4=EC=A4=91=EB=8B=A8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=A0=81=EC=9A=A9=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 03b18358..761892c2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Build and Deploy to EC2 on: push: - branches: [ "production", "main", "feat/173-docker-deploy" ] + branches: [ "production", "main" ] pull_request: branches: [ "production", "main" ] From be8a38508e6fa8573e447947eb08aeb215505deb Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 28 May 2024 11:31:44 +0900 Subject: [PATCH 30/31] =?UTF-8?q?feat:=20=EB=AC=B4=EC=A4=91=EB=8B=A8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=A0=81=EC=9A=A9=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 761892c2..491be8db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,7 @@ jobs: shell: bash - name: Build with Gradle - run: ./gradlew clean build -x test + run: ./gradlew clean build - name: docker login uses: docker /login-action@v2 From 4c83416b918349ac86698658d8f53e767ebfedb9 Mon Sep 17 00:00:00 2001 From: kimdozzi Date: Tue, 28 May 2024 11:59:20 +0900 Subject: [PATCH 31/31] =?UTF-8?q?feat:=20=EB=AC=B4=EC=A4=91=EB=8B=A8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=A0=81=EC=9A=A9=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 491be8db..1bee53be 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,10 +1,8 @@ name: Build and Deploy to EC2 on: - push: - branches: [ "production", "main" ] pull_request: - branches: [ "production", "main" ] + branches: [ "production" ] jobs: build-docker-image: