From b027efa3cd7b9ac3ebc365174bb9b02911329fce Mon Sep 17 00:00:00 2001 From: Honghyeonji <66579773+Honghyeonji@users.noreply.github.com> Date: Wed, 13 Nov 2024 21:01:07 +0900 Subject: [PATCH 1/6] Create boolock-dev-cicd.yml --- .github/workflows/boolock-dev-cicd.yml | 88 ++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 .github/workflows/boolock-dev-cicd.yml diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml new file mode 100644 index 00000000..5d7010d9 --- /dev/null +++ b/.github/workflows/boolock-dev-cicd.yml @@ -0,0 +1,88 @@ +name: ci/cd action + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Install Pnpm + run: npm install -g pnpm + + - name: Package install with pnpm + run : | + pnpm install:all + + - name: Set BE .env + run: | + echo "MONGO_URI=${{ secrets.MONGO_URI }}" > apps/server/.env + echo "SSH_HOST=${{ secrets.SSH_HOST }}" > apps/server/.env + echo "SSH_PORT=${{ secrets.SSH_PORT }}" > apps/server/.env + echo "SSH_USER=${{ secrets.SSH_USER }}" > apps/server/.env + echo "SSH_PASSWORD=${{ secrets.SSH_PASSWORD }}" > apps/server/.env + echo "SSH_DATABASE_HOST=${{ secrets.SSH_DATABASE_HOST }}" > apps/server/.env + echo "SSH_DATABASE_PORT=${{ secrets.SSH_DATABASE_PORT }}" > apps/server/.env + echo "LOCAL_PORT=${{ secrets.LOCAL_PORT }}" > apps/server/.env + + - name: Buld Frontend + run: | + cd apps/client + pnpm run build + + - name: Build Backend + run: | + cd apps/server + pnpm run build + + - name: Build the Docker image + run: | + docker build . --file Dockerfile.base --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 + docker build . --file apps/client/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 + docker build . --file apps/server/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Docker Hub push + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Login to Docker Hub + run: sudo docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Deploy with docker + uses: appleboy/ssh-action@v0.1.6 + with: + host: ${{ secrets.SSH_HOST }} + username: ${{ secrets.SSH_USER }} + key: ${{ secrets.SSH_PASSWORD }} + port: ${{ secrets.SSH_PORT }} + script: | + cd boolock/web31-BooLock + git checkout dev + git pull + sudo docker-compose build base + sudo docker-compose pull + sudo docker-compose down + sudo docker-compose up -d + sudo docker image prune -f From d59c5132347bb4da8e0e02c2aae1a8150c78c9fc Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Wed, 13 Nov 2024 21:19:09 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=99=80=20chore:=20=EA=B9=83=ED=97=88?= =?UTF-8?q?=EB=B8=8C=20=EC=95=A1=EC=85=98=20=EC=8A=A4=ED=81=AC=EB=A6=BD?= =?UTF-8?q?=ED=8A=B8=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 97 +++++++++++++------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index 5d7010d9..6e30ae78 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -2,67 +2,66 @@ name: ci/cd action on: push: - branches: [ "dev" ] + branches: ['dev'] pull_request: - branches: [ "dev" ] + branches: ['dev'] jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: '20.x' + - uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Install Pnpm + run: npm install -g pnpm - - name: Install Pnpm - run: npm install -g pnpm + - name: Package install with pnpm + run: pnpm install:all - - name: Package install with pnpm - run : | - pnpm install:all + - name: Set BE .env + run: | + printf "MONGO_URI=\"${{ secrets.MONGO_URI }}\"\n" > apps/server/.env + echo "SSH_HOST=${{ secrets.SSH_HOST }}" >> apps/server/.env + echo "SSH_PORT=${{ secrets.SSH_PORT }}" >> apps/server/.env + echo "SSH_USER=${{ secrets.SSH_USER }}" >> apps/server/.env + echo "SSH_PASSWORD=${{ secrets.SSH_PASSWORD }}" >> apps/server/.env + echo "SSH_DATABASE_HOST=${{ secrets.SSH_DATABASE_HOST }}" >> apps/server/.env + echo "SSH_DATABASE_PORT=${{ secrets.SSH_DATABASE_PORT }}" >> apps/server/.env + echo "LOCAL_PORT=${{ secrets.LOCAL_PORT }}" >> apps/server/.env - - name: Set BE .env - run: | - echo "MONGO_URI=${{ secrets.MONGO_URI }}" > apps/server/.env - echo "SSH_HOST=${{ secrets.SSH_HOST }}" > apps/server/.env - echo "SSH_PORT=${{ secrets.SSH_PORT }}" > apps/server/.env - echo "SSH_USER=${{ secrets.SSH_USER }}" > apps/server/.env - echo "SSH_PASSWORD=${{ secrets.SSH_PASSWORD }}" > apps/server/.env - echo "SSH_DATABASE_HOST=${{ secrets.SSH_DATABASE_HOST }}" > apps/server/.env - echo "SSH_DATABASE_PORT=${{ secrets.SSH_DATABASE_PORT }}" > apps/server/.env - echo "LOCAL_PORT=${{ secrets.LOCAL_PORT }}" > apps/server/.env - - - name: Buld Frontend - run: | - cd apps/client - pnpm run build + - name: Buld Frontend + run: | + cd apps/client + pnpm run build - - name: Build Backend - run: | - cd apps/server - pnpm run build + - name: Build Backend + run: | + cd apps/server + pnpm run build - - name: Build the Docker image - run: | - docker build . --file Dockerfile.base --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 - docker build . --file apps/client/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 - docker build . --file apps/server/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 + - name: Build the Docker image + run: | + docker build . --file Dockerfile.base --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 + docker build . --file apps/client/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 + docker build . --file apps/server/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Docker Hub push + run: | + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 - - name: Docker Hub push - run: | - docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 - docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 - docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 - deploy: needs: build runs-on: ubuntu-latest @@ -81,6 +80,10 @@ jobs: cd boolock/web31-BooLock git checkout dev git pull + + printf "MONGO_URI=\"${{ secrets.MONGO_URI }}\"\n" > apps/server/.env + echo "IS_LOCAL=false" >> apps/server/.env + sudo docker-compose build base sudo docker-compose pull sudo docker-compose down From 6d477c6295affaa1a8745b23789d043a384cd560 Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Wed, 13 Nov 2024 21:21:59 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=99=80=20chore:=20=EA=B9=83=ED=97=88?= =?UTF-8?q?=EB=B8=8C=20=EC=95=A1=EC=85=98=20mongo=20url=20=EA=B0=80?= =?UTF-8?q?=EC=A0=B8=EC=98=A4=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index 6e30ae78..c7ddeb49 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -25,7 +25,7 @@ jobs: - name: Set BE .env run: | - printf "MONGO_URI=\"${{ secrets.MONGO_URI }}\"\n" > apps/server/.env + echo "MONGO_URI=\"${{ secrets.MONGO_URI }}\"" > apps/server/.env echo "SSH_HOST=${{ secrets.SSH_HOST }}" >> apps/server/.env echo "SSH_PORT=${{ secrets.SSH_PORT }}" >> apps/server/.env echo "SSH_USER=${{ secrets.SSH_USER }}" >> apps/server/.env @@ -81,7 +81,7 @@ jobs: git checkout dev git pull - printf "MONGO_URI=\"${{ secrets.MONGO_URI }}\"\n" > apps/server/.env + echo "MONGO_URI=\"${{ secrets.MONGO_URI }}\"" > apps/server/.env echo "IS_LOCAL=false" >> apps/server/.env sudo docker-compose build base From 7d07767976d137e53ea235e55c2457d9d1e79e31 Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Wed, 13 Nov 2024 21:29:35 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=99=80=20chore:=20=EA=B9=83=ED=97=88?= =?UTF-8?q?=EB=B8=8C=20=EC=95=A1=EC=85=98=20=EC=A4=91=20client=20docker?= =?UTF-8?q?=EA=B0=80=20base-image=EB=A5=BC=20=EC=B0=BE=EC=A7=80=20?= =?UTF-8?q?=EB=AA=BB=ED=95=98=EB=8A=94=20=EC=97=90=EB=9F=AC=EB=A5=BC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index c7ddeb49..f15cbefd 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -44,9 +44,13 @@ jobs: cd apps/server pnpm run build - - name: Build the Docker image + - name: Build base image run: | docker build . --file Dockerfile.base --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_base_test:1.0 base-image + + - name: Build frontend and backend images + run: | docker build . --file apps/client/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:1.0 docker build . --file apps/server/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:1.0 From 4dc5ab4c39c6fde676928f326b2a57c24bfd7d1f Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Wed, 13 Nov 2024 21:34:19 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=99=80=20chore:=20ssh=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EC=84=A4=EC=A0=95=20=EB=B6=80=EB=B6=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20key->password=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index f15cbefd..778d017d 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -78,7 +78,7 @@ jobs: with: host: ${{ secrets.SSH_HOST }} username: ${{ secrets.SSH_USER }} - key: ${{ secrets.SSH_PASSWORD }} + password: ${{ secrets.SSH_PASSWORD }} port: ${{ secrets.SSH_PORT }} script: | cd boolock/web31-BooLock From a6f1d3965e328c3da037a388059c10f9839ce3e6 Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Thu, 14 Nov 2024 12:05:08 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=99=80=20chore:=20=EC=95=A1=EC=85=98?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=98=A4=ED=83=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index 778d017d..ebac751a 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -88,8 +88,8 @@ jobs: echo "MONGO_URI=\"${{ secrets.MONGO_URI }}\"" > apps/server/.env echo "IS_LOCAL=false" >> apps/server/.env - sudo docker-compose build base - sudo docker-compose pull - sudo docker-compose down - sudo docker-compose up -d + sudo docker compose build base + sudo docker compose pull + sudo docker compose down + sudo docker compose up -d sudo docker image prune -f