From 5409bdb0cbc03867d1f06acb8d0509875bfb8592 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 10:37:53 -0500 Subject: [PATCH 1/9] Add local cache --- .github/workflows/docker-image.yml | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 4654f6a00..ee1dc7d13 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,6 +17,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -28,6 +35,8 @@ jobs: load: true context: backend tags: infisical/backend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - name: โป Spawn backend container and dependencies run: | docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull @@ -45,6 +54,13 @@ jobs: tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest platforms: linux/amd64,linux/arm64 + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache frontend-image: name: Build frontend image @@ -60,6 +76,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -71,6 +94,8 @@ jobs: load: true context: frontend tags: infisical/frontend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - name: โป Spawn frontend container @@ -92,3 +117,10 @@ jobs: platforms: linux/amd64,linux/arm64 build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From b10e28b9b56f064bb2e56657b4786db0cf6b8c02 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 10:44:51 -0500 Subject: [PATCH 2/9] set push to false to test cache --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ee1dc7d13..bc54e43a3 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,7 +49,7 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: true + push: false context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest @@ -110,7 +110,7 @@ jobs: - name: ๐Ÿ—๏ธ Build frontend and push uses: docker/build-push-action@v3 with: - push: true + push: false context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest From c81320c09d7d90a8f6a855dde605c582ee353d22 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:14:40 -0500 Subject: [PATCH 3/9] remove frontend testing --- .github/workflows/docker-image.yml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bc54e43a3..a0d7ae792 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -91,32 +91,14 @@ jobs: - name: ๐Ÿ“ฆ Build frontend and export to Docker uses: docker/build-push-action@v3 with: - load: true + # load: true + push: false context: frontend tags: infisical/frontend:test cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - name: โป Spawn frontend container - run: | - docker run -d --rm --name infisical-frontend-test infisical/frontend:test - - name: ๐Ÿงช Test frontend image - run: | - ./.github/resources/healthcheck.sh infisical-frontend-test - - name: โป Shut down frontend container - run: | - docker stop infisical-frontend-test - - name: ๐Ÿ—๏ธ Build frontend and push - uses: docker/build-push-action@v3 - with: - push: false - context: frontend - tags: infisical/frontend:${{ steps.commit.outputs.short }}, - infisical/frontend:latest - platforms: linux/amd64,linux/arm64 - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 From 07e6eb88ea68b15c75a9a62cbaa83ab488bab110 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:21:14 -0500 Subject: [PATCH 4/9] use github cache --- .github/workflows/docker-image.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a0d7ae792..d8cf08045 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -76,13 +76,6 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -95,8 +88,8 @@ jobs: push: false context: frontend tags: infisical/frontend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + cache-from: type=gha + cache-to: type=gha,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix From 3eb2209eb83dd4ebff9384074da80ef430ade91b Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:35:58 -0500 Subject: [PATCH 5/9] add cache to build after test step --- .github/workflows/docker-image.yml | 35 ++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d8cf08045..b2cda6fe5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -76,6 +76,13 @@ jobs: uses: docker/setup-qemu-action@v2 - name: ๐Ÿ”ง Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: ๐Ÿ‹ Login to Docker Hub uses: docker/login-action@v2 with: @@ -84,12 +91,32 @@ jobs: - name: ๐Ÿ“ฆ Build frontend and export to Docker uses: docker/build-push-action@v3 with: - # load: true - push: false + load: true context: frontend tags: infisical/frontend:test - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - name: โป Spawn frontend container + run: | + docker run -d --rm --name infisical-frontend-test infisical/frontend:test + - name: ๐Ÿงช Test frontend image + run: | + ./.github/resources/healthcheck.sh infisical-frontend-test + - name: โป Shut down frontend container + run: | + docker stop infisical-frontend-test + - name: ๐Ÿ—๏ธ Build frontend and push + uses: docker/build-push-action@v3 + with: + push: false + context: frontend + tags: infisical/frontend:${{ steps.commit.outputs.short }}, + infisical/frontend:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max build-args: | POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - # Temp fix From e4d302b7e1a67a537acdce45dd28a0f4b84a55c2 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:56:42 -0500 Subject: [PATCH 6/9] Add cache to build step in backend --- .github/workflows/docker-image.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index b2cda6fe5..579f6bd46 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,11 +49,13 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: false + push: push context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # Temp fix # https://github.com/docker/build-push-action/issues/252 # https://github.com/moby/buildkit/issues/1896 @@ -110,7 +112,7 @@ jobs: - name: ๐Ÿ—๏ธ Build frontend and push uses: docker/build-push-action@v3 with: - push: false + push: true context: frontend tags: infisical/frontend:${{ steps.commit.outputs.short }}, infisical/frontend:latest From 97f77dcadaee81edc7917e0adcfd64f0956eb291 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 11:59:17 -0500 Subject: [PATCH 7/9] set push to true for backend workflow --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 579f6bd46..e138c83f9 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -49,7 +49,7 @@ jobs: - name: ๐Ÿ—๏ธ Build backend and push uses: docker/build-push-action@v3 with: - push: push + push: true context: backend tags: infisical/backend:${{ steps.commit.outputs.short }}, infisical/backend:latest From be8a274e5a6613b8d4628dc5ff1365479f4f77c5 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 13:20:37 -0500 Subject: [PATCH 8/9] create separate frontend workflow --- .../workflows/push-frontend-image-docker.yml | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 .github/workflows/push-frontend-image-docker.yml diff --git a/.github/workflows/push-frontend-image-docker.yml b/.github/workflows/push-frontend-image-docker.yml new file mode 100644 index 000000000..1b948f19b --- /dev/null +++ b/.github/workflows/push-frontend-image-docker.yml @@ -0,0 +1,130 @@ +name: Push frontend to Dockerhub + +on: [workflow_dispatch] + +jobs: + # backend-image: + # name: Build backend image + # runs-on: ubuntu-latest + + # steps: + # - name: โ˜๏ธ Checkout source + # uses: actions/checkout@v3 + # - name: Save commit hashes for tag + # id: commit + # uses: pr-mpt/actions-commit-hash@v2 + # - name: ๐Ÿ”ง Set up QEMU + # uses: docker/setup-qemu-action@v2 + # - name: ๐Ÿ”ง Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + # - name: Cache Docker layers + # uses: actions/cache@v3 + # with: + # path: /tmp/.buildx-cache + # key: ${{ runner.os }}-buildx-${{ github.sha }} + # restore-keys: | + # ${{ runner.os }}-buildx- + # - name: ๐Ÿ‹ Login to Docker Hub + # uses: docker/login-action@v2 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_TOKEN }} + # - name: ๐Ÿ“ฆ Build backend and export to Docker + # uses: docker/build-push-action@v3 + # with: + # load: true + # context: backend + # tags: infisical/backend:test + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - name: โป Spawn backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull + # - name: ๐Ÿงช Test backend image + # run: | + # ./.github/resources/healthcheck.sh infisical-backend-test + # - name: โป Shut down backend container and dependencies + # run: | + # docker compose -f .github/resources/docker-compose.be-test.yml down + # - name: ๐Ÿ—๏ธ Build backend and push + # uses: docker/build-push-action@v3 + # with: + # push: true + # context: backend + # tags: infisical/backend:${{ steps.commit.outputs.short }}, + # infisical/backend:latest + # platforms: linux/amd64,linux/arm64 + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # - # Temp fix + # # https://github.com/docker/build-push-action/issues/252 + # # https://github.com/moby/buildkit/issues/1896 + # name: Move cache + # run: | + # rm -rf /tmp/.buildx-cache + # mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + frontend-image: + name: Build frontend image + runs-on: ubuntu-latest + + steps: + - name: โ˜๏ธ Checkout source + uses: actions/checkout@v3 + - name: Save commit hashes for tag + id: commit + uses: pr-mpt/actions-commit-hash@v2 + - name: ๐Ÿ”ง Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: ๐Ÿ‹ Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: ๐Ÿ“ฆ Build frontend and export to Docker + uses: docker/build-push-action@v3 + with: + load: true + context: frontend + tags: infisical/frontend:test + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - name: โป Spawn frontend container + run: | + docker run -d --rm --name infisical-frontend-test infisical/frontend:test + - name: ๐Ÿงช Test frontend image + run: | + ./.github/resources/healthcheck.sh infisical-frontend-test + - name: โป Shut down frontend container + run: | + docker stop infisical-frontend-test + - name: ๐Ÿ—๏ธ Build frontend and push + uses: docker/build-push-action@v3 + with: + push: true + context: frontend + tags: infisical/frontend:${{ steps.commit.outputs.short }}, + infisical/frontend:latest + platforms: linux/amd64,linux/arm64 + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + build-args: | + POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} + - # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From b8edcab0d598fb1138bce7703a825d18f0cbdbd5 Mon Sep 17 00:00:00 2001 From: Maidul Islam Date: Tue, 10 Jan 2023 13:25:34 -0500 Subject: [PATCH 9/9] delete push-frontend-image-docker --- .../workflows/push-frontend-image-docker.yml | 130 ------------------ 1 file changed, 130 deletions(-) delete mode 100644 .github/workflows/push-frontend-image-docker.yml diff --git a/.github/workflows/push-frontend-image-docker.yml b/.github/workflows/push-frontend-image-docker.yml deleted file mode 100644 index 1b948f19b..000000000 --- a/.github/workflows/push-frontend-image-docker.yml +++ /dev/null @@ -1,130 +0,0 @@ -name: Push frontend to Dockerhub - -on: [workflow_dispatch] - -jobs: - # backend-image: - # name: Build backend image - # runs-on: ubuntu-latest - - # steps: - # - name: โ˜๏ธ Checkout source - # uses: actions/checkout@v3 - # - name: Save commit hashes for tag - # id: commit - # uses: pr-mpt/actions-commit-hash@v2 - # - name: ๐Ÿ”ง Set up QEMU - # uses: docker/setup-qemu-action@v2 - # - name: ๐Ÿ”ง Set up Docker Buildx - # uses: docker/setup-buildx-action@v2 - # - name: Cache Docker layers - # uses: actions/cache@v3 - # with: - # path: /tmp/.buildx-cache - # key: ${{ runner.os }}-buildx-${{ github.sha }} - # restore-keys: | - # ${{ runner.os }}-buildx- - # - name: ๐Ÿ‹ Login to Docker Hub - # uses: docker/login-action@v2 - # with: - # username: ${{ secrets.DOCKERHUB_USERNAME }} - # password: ${{ secrets.DOCKERHUB_TOKEN }} - # - name: ๐Ÿ“ฆ Build backend and export to Docker - # uses: docker/build-push-action@v3 - # with: - # load: true - # context: backend - # tags: infisical/backend:test - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - name: โป Spawn backend container and dependencies - # run: | - # docker compose -f .github/resources/docker-compose.be-test.yml up --wait --quiet-pull - # - name: ๐Ÿงช Test backend image - # run: | - # ./.github/resources/healthcheck.sh infisical-backend-test - # - name: โป Shut down backend container and dependencies - # run: | - # docker compose -f .github/resources/docker-compose.be-test.yml down - # - name: ๐Ÿ—๏ธ Build backend and push - # uses: docker/build-push-action@v3 - # with: - # push: true - # context: backend - # tags: infisical/backend:${{ steps.commit.outputs.short }}, - # infisical/backend:latest - # platforms: linux/amd64,linux/arm64 - # cache-from: type=local,src=/tmp/.buildx-cache - # cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - # - # Temp fix - # # https://github.com/docker/build-push-action/issues/252 - # # https://github.com/moby/buildkit/issues/1896 - # name: Move cache - # run: | - # rm -rf /tmp/.buildx-cache - # mv /tmp/.buildx-cache-new /tmp/.buildx-cache - - frontend-image: - name: Build frontend image - runs-on: ubuntu-latest - - steps: - - name: โ˜๏ธ Checkout source - uses: actions/checkout@v3 - - name: Save commit hashes for tag - id: commit - uses: pr-mpt/actions-commit-hash@v2 - - name: ๐Ÿ”ง Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: ๐Ÿ”ง Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Cache Docker layers - uses: actions/cache@v3 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - name: ๐Ÿ‹ Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: ๐Ÿ“ฆ Build frontend and export to Docker - uses: docker/build-push-action@v3 - with: - load: true - context: frontend - tags: infisical/frontend:test - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - name: โป Spawn frontend container - run: | - docker run -d --rm --name infisical-frontend-test infisical/frontend:test - - name: ๐Ÿงช Test frontend image - run: | - ./.github/resources/healthcheck.sh infisical-frontend-test - - name: โป Shut down frontend container - run: | - docker stop infisical-frontend-test - - name: ๐Ÿ—๏ธ Build frontend and push - uses: docker/build-push-action@v3 - with: - push: true - context: frontend - tags: infisical/frontend:${{ steps.commit.outputs.short }}, - infisical/frontend:latest - platforms: linux/amd64,linux/arm64 - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max - build-args: | - POSTHOG_API_KEY=${{ secrets.PUBLIC_POSTHOG_API_KEY }} - - # Temp fix - # https://github.com/docker/build-push-action/issues/252 - # https://github.com/moby/buildkit/issues/1896 - name: Move cache - run: | - rm -rf /tmp/.buildx-cache - mv /tmp/.buildx-cache-new /tmp/.buildx-cache