From d912b298887e6d93e85d589aabd2f2e0cfcf6a94 Mon Sep 17 00:00:00 2001 From: Honghyeonji Date: Mon, 13 Jan 2025 16:48:42 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20refactor:=20github=20actions=20?= =?UTF-8?q?=EC=BA=90=EC=8B=9C=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/boolock-dev-cicd.yml | 55 +++++++++++--------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/.github/workflows/boolock-dev-cicd.yml b/.github/workflows/boolock-dev-cicd.yml index 3a1d0e6..9b9e011 100644 --- a/.github/workflows/boolock-dev-cicd.yml +++ b/.github/workflows/boolock-dev-cicd.yml @@ -12,15 +12,14 @@ jobs: steps: - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 + + - name: Cache Docker layers + uses: actions/cache@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker- - name: Set BE .env run: | @@ -43,35 +42,27 @@ jobs: echo "${{ secrets.SSL_FULLCHAIN }}" > apps/client/ssl/fullchain.pem echo "${{ secrets.SSL_PRIVKEY }}" > apps/client/ssl/privkey.pem - - name: Build and Push Base Image + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build base image run: | - docker buildx build \ - --file Dockerfile.base \ - --tag ${{ secrets.DOCKERHUB_USERNAME }}/base-image:latest \ - --cache-from=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/base-image:cache \ - --cache-to=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/base-image:cache,mode=max \ - --push . - - - name: Tag Base Image Locally - run: docker tag ${{ secrets.DOCKERHUB_USERNAME }}/base-image:latest base-image + docker build . --file Dockerfile.base --tag ${{ secrets.DOCKERHUB_USERNAME }}/base-image:latest + docker tag ${{ secrets.DOCKERHUB_USERNAME }}/base-image:latest base-image - - name: Build and Push Frontend Image + - name: Build frontend and backend images run: | - docker buildx build \ - --file apps/client/Dockerfile \ - --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:latest \ - --cache-from=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:cache \ - --cache-to=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:cache,mode=max \ - --push . + docker build . --file apps/client/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:latest + docker build . --file apps/server/Dockerfile --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:latest - - name: Build and Push Backend Image + - name: Docker Hub push run: | - docker buildx build \ - --file apps/server/Dockerfile \ - --tag ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:latest \ - --cache-from=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:cache \ - --cache-to=type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:cache,mode=max \ - --push . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/base-image:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_client_test:latest + docker push ${{ secrets.DOCKERHUB_USERNAME }}/boolock_server_test:latest deploy: needs: build