From 481d6a0c8a13f5ba6e8e50b879fa3c70de7fb1c7 Mon Sep 17 00:00:00 2001 From: Jungu Lee <1zzangjun@gmail.com> Date: Sun, 5 Nov 2023 01:56:54 +0900 Subject: [PATCH] =?UTF-8?q?NEW=20:=20Client=20-=20Storybook=20CD=20?= =?UTF-8?q?=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Storybook-CD.yml | 40 ++++++++++++++++++++++++++++++ client/Dockerfile | 4 +-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/Storybook-CD.yml diff --git a/.github/workflows/Storybook-CD.yml b/.github/workflows/Storybook-CD.yml new file mode 100644 index 0000000..33d3667 --- /dev/null +++ b/.github/workflows/Storybook-CD.yml @@ -0,0 +1,40 @@ +name: Storybook CD +on: + push: + branches: ["main"] + paths: client/** +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Build Docker Image + run: docker build -f storybook.Dockerfile -t ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_STORYBOOK_NAME }}:latest . + working-directory: ./client + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.CLIENT_DOCKER_USERNAME }} + password: ${{ secrets.CLIENT_DOCKER_PASSWORD }} + + - name: Push Image to Dockerhub + run: docker push ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_STORYBOOK_NAME }}:latest + + - name: executing remote ssh commands using password + uses: appleboy/ssh-action@v0.1.4 + with: + host: ${{ secrets.STORYBOOK_CLOUD_HOST }} + username: root + password: ${{ secrets.STORYBOOK_CLOUD_PASSWORD }} + port: ${{ secrets.STORYBOOK_CLOUD_PORT }} + script: | + sudo docker pull ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_STORYBOOK_NAME }}:latest + sudo docker rm -f $(docker ps -qa) + sudo docker run --name storybook-static -d -p 80:80 ${{ secrets.CLIENT_STORYBOOK_REPO }}/${{ secrets.CLIENT_STORYBOOK_NAME }}:latest + docker image prune -f diff --git a/client/Dockerfile b/client/Dockerfile index 6364b91..dcab8fa 100644 --- a/client/Dockerfile +++ b/client/Dockerfile @@ -56,9 +56,9 @@ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static USER nextjs -EXPOSE 3000 +EXPOSE ${PORT} -ENV PORT 3000 +ENV PORT ${PORT} # set hostname to localhost ENV HOSTNAME "0.0.0.0"