From 4dbe92f8e7b2f06ad34d080ff0364554feba65e3 Mon Sep 17 00:00:00 2001 From: Chanho Lee <101349340+devchlee12@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:23:38 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[PC-333]=20=EB=B9=8C=EB=93=9C=EC=8B=9C=20?= =?UTF-8?q?=EC=8B=A4=ED=96=89=20=EA=B6=8C=ED=95=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d5a4a62..77bd5db 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -42,7 +42,9 @@ jobs: # gradle build - name: Build with Gradle - run: ./gradlew build -x test + run: | + chmod u+x ./gradlew + ./gradlew build -x test # docker build & push to develop - name: Docker build & push to dev @@ -67,4 +69,4 @@ jobs: sudo docker ps sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test-dev sudo docker run -d -p 8080:8080 --add-host=localhost:host-gateway ${{ secrets.DOCKER_USERNAME }}/docker-test-dev - sudo docker image prune -f \ No newline at end of file + sudo docker image prune -f From 1712c95943781631a2d40605f577493fc3e62ed1 Mon Sep 17 00:00:00 2001 From: Chanho Lee Date: Tue, 28 Jan 2025 16:54:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[PC-333]=20feat:=20=EC=9A=B4=EC=98=81?= =?UTF-8?q?=EC=84=9C=EB=B2=84=EC=9A=A9=20Dockerfile=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile-prod | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 Dockerfile-prod diff --git a/Dockerfile-prod b/Dockerfile-prod new file mode 100644 index 0000000..92143ae --- /dev/null +++ b/Dockerfile-prod @@ -0,0 +1,7 @@ +FROM eclipse-temurin:17-jdk + +ARG JAR_FILE=api/build/libs/*.jar + +COPY ${JAR_FILE} app.jar + +ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file From 68c6b3058b0173dd78fb375bf32177895faca154 Mon Sep 17 00:00:00 2001 From: Chanho Lee Date: Tue, 28 Jan 2025 16:54:20 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[PC-333]=20feat:=20main=20=EB=B8=8C?= =?UTF-8?q?=EB=9E=9C=EC=B9=98=20=EB=A8=B8=EC=A7=80=EC=8B=9C=20=EC=9A=B4?= =?UTF-8?q?=EC=97=AC=EC=84=9C=EB=B2=84=EC=97=90=20=EB=B0=B0=ED=8F=AC=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 50 +++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 77bd5db..6d959c9 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -29,10 +29,9 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - # secret yml 파일 생성 + # secret yml 파일 생성 - dev - name: make application-secret.yml if: | - contains(github.ref, 'main') || contains(github.ref, 'develope') run: | cd ./api/src/main/resources @@ -40,8 +39,9 @@ jobs: echo "${{ secrets.YML }}" > ./application-secret.yml shell: bash - # gradle build + # gradle build - dev - name: Build with Gradle + if: contains(github.ref, 'develope') run: | chmod u+x ./gradlew ./gradlew build -x test @@ -68,5 +68,47 @@ jobs: script: | sudo docker ps sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test-dev - sudo docker run -d -p 8080:8080 --add-host=localhost:host-gateway ${{ secrets.DOCKER_USERNAME }}/docker-test-dev + sudo docker run -d -p 8080:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-test-dev sudo docker image prune -f + + # secret yml 생성 - prod + - name: make application-secret.yml + if: | + contains(github.ref, 'main') + run: | + cd ./api/src/main/resources + touch ./application-secret.yml + echo "${{ secrets.PROD_YML }}" > ./application-secret.yml + shell: bash + + # gradle build + - name: Build with Gradle + if: contains(github.ref, 'main') + run: | + chmod u+x ./gradlew + ./gradlew build -x test + + # docker build & push to prod + - name: Docker build & push to prod + if: contains(github.ref, 'main') + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f Dockerfile-prod -t ${{ secrets.DOCKER_USERNAME }}/docker-prod . + docker push ${{ secrets.DOCKER_USERNAME }}/docker-prod + + ## deploy to prod + - name: Deploy to prod + uses: appleboy/ssh-action@master + id: deploy-prod + if: contains(github.ref, 'main') + with: + host: ${{ secrets.HOST_PROD }} + username: ${{ secrets.USERNAME_PROD }} + password: ${{ secrets.PASSWORD_PROD }} + port: 22 + key: ${{ secrets.PRIVATE_KEY_PROD }} + script: | + sudo docker ps + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-prod + sudo docker run -d -p 80:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-prod + sudo docker image prune -f \ No newline at end of file From 5999eb491f8c95dfd01a3b14afc365e284d7939d Mon Sep 17 00:00:00 2001 From: Chanho Lee Date: Tue, 28 Jan 2025 17:35:39 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[PC-333]=20feat:=20=EA=B0=9C=EB=B0=9C=20?= =?UTF-8?q?=EC=96=B4=EB=93=9C=EB=AF=BC,=20=EC=9A=B4=EC=98=81=20=EC=96=B4?= =?UTF-8?q?=EB=93=9C=EB=AF=BC=20=EC=84=9C=EB=B2=84=20CICD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd.yml | 85 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index 6d959c9..62dc317 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -71,6 +71,49 @@ jobs: sudo docker run -d -p 8080:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-test-dev sudo docker image prune -f + # secret yml 파일 생성 - admin + - name: make application-secret.yml + if: | + contains(github.ref, 'develope') + run: | + cd ./admin/src/main/resources + touch ./application-secret.yml + echo "${{ secrets.ADMIN_YML }}" > ./application-secret.yml + shell: bash + + # gradle build - admin + - name: Build with Gradle + if: contains(github.ref, 'develope') + run: | + chmod u+x ./gradlew + ./gradlew build -x test + + # docker build & push to admin + - name: Docker build & push to admin + if: contains(github.ref, 'develope') + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f Dockerfile-admin -t ${{ secrets.DOCKER_USERNAME }}/docker-admin . + docker push ${{ secrets.DOCKER_USERNAME }}/docker-admin + + ## deploy to admin + - name: Deploy to admin + uses: appleboy/ssh-action@master + id: deploy-admin + if: contains(github.ref, 'develope') + with: + host: ${{ secrets.HOST_DEV }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: 22 + key: ${{ secrets.PRIVATE_KEY }} + script: | + sudo docker ps + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-admin + sudo docker run -d -p 8081:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-admin + sudo docker image prune -f + + # secret yml 생성 - prod - name: make application-secret.yml if: | @@ -111,4 +154,46 @@ jobs: sudo docker ps sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-prod sudo docker run -d -p 80:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-prod + sudo docker image prune -f + + # secret yml 생성 - prod-admin + - name: make application-secret.yml + if: | + contains(github.ref, 'main') + run: | + cd ./admin/src/main/resources + touch ./application-secret.yml + echo "${{ secrets.PROD_ADMIN_YML }}" > ./application-secret.yml + shell: bash + + # gradle build + - name: Build with Gradle + if: contains(github.ref, 'main') + run: | + chmod u+x ./gradlew + ./gradlew build -x test + + # docker build & push to prod-admin + - name: Docker build & push to prod-admin + if: contains(github.ref, 'main') + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f Dockerfile-admin -t ${{ secrets.DOCKER_USERNAME }}/docker-prod-admin . + docker push ${{ secrets.DOCKER_USERNAME }}/docker-prod-admin + + ## deploy to prod-admin + - name: Deploy to prod-admin + uses: appleboy/ssh-action@master + id: deploy-prod-admin + if: contains(github.ref, 'main') + with: + host: ${{ secrets.HOST_PROD_ADMIN }} + username: ${{ secrets.USERNAME_PROD_ADMIN }} + password: ${{ secrets.PASSWORD_PROD_ADMIN }} + port: 22 + key: ${{ secrets.PRIVATE_KEY_PROD_ADMIN }} + script: | + sudo docker ps + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-prod-admin + sudo docker run -d -p 80:8080 --network piece-nw ${{ secrets.DOCKER_USERNAME }}/docker-prod-admin sudo docker image prune -f \ No newline at end of file