From fdde0d536cf80a2c850da087d751cecf8aeb93ca Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 6 May 2024 16:00:02 +0800 Subject: [PATCH 1/3] ci: Remove duplicate docker-build job Signed-off-by: Kevin Su --- .github/workflows/checks.yml | 13 ------ .github/workflows/component_docker_build.yml | 49 -------------------- .github/workflows/publish.yml | 2 + 3 files changed, 2 insertions(+), 62 deletions(-) delete mode 100644 .github/workflows/component_docker_build.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f858c010ab..033eb158e6 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -64,19 +64,6 @@ jobs: go-version: ${{ needs.unpack-envvars.outputs.go-version }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - docker-build: - strategy: - fail-fast: false - matrix: - component: - - datacatalog - - flyteadmin - - flytecopilot - - flytepropeller - name: Docker Build Images - uses: ./.github/workflows/component_docker_build.yml - with: - component: ${{ matrix.component }} # TODO(monorepo): these tests are broken. They never test an actual change. # endtoend: diff --git a/.github/workflows/component_docker_build.yml b/.github/workflows/component_docker_build.yml deleted file mode 100644 index b4eb882a26..0000000000 --- a/.github/workflows/component_docker_build.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build Docker Image - -on: - workflow_call: - inputs: - component: - required: true - type: string - outputs: - cache_key: - description: "Docker Cache key" - value: ${{ jobs.build_docker.outputs.cache_key }} -jobs: - build_docker: - runs-on: ubuntu-latest - outputs: - cache_key: ${{ steps.cache_key.outputs.cache_key }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - id: load-docker-cache - name: Load Docker Cache - uses: actions/cache@v3 - with: - path: /tmp/tmp/docker-images-${{ inputs.component }} - key: /tmp/docker-images-${{ github.run_id }}-${{ inputs.component }} - restore-keys: | - /tmp/docker-images- - - name: Set cache key output - id: cache_key - run: | - echo ::set-output name=cache_key::/tmp/docker-images-${{ github.run_id }} - - name: Prime docker cache - run: (docker load -i /tmp/tmp/docker-images/snapshot-builder.tar || true) && (docker load -i /tmp/tmp/docker-images/snapshot.tar || true) - - name: Build dockerfile - env: - # We are unable to leverage docker buildx here without changing the - # caching mechanism significantly. See here for the caching options - # available for docker buildx: https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from - # For now at least enable DOCKER_BUILDKIT for faster builds. Eventually we - # should rewrite this pipeline to use docker buildx with cache type=gha. - DOCKER_BUILDKIT: "1" - run: | - docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:builder --target builder --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . - docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:latest --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . - - - name: Tag and cache docker image - run: | - mkdir -p /tmp/tmp/docker-images-${{ inputs.component }} && docker save ${{ github.repository_owner }}/${{ inputs.component }}:builder -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-builder-${{ inputs.component }}.tar && docker save ${{ github.repository_owner }}/${{ inputs.component }}:latest -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-${{ inputs.component }}.tar diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9349144454..fe2f8535af 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -66,3 +66,5 @@ jobs: platforms: linux/arm64,linux/amd64 push: ${{ inputs.push }} tags: ${{ steps.tags.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max From 56b0ccaac1bee8129918ef49a505137422de75d8 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 6 May 2024 17:24:02 +0800 Subject: [PATCH 2/3] fix-test Signed-off-by: Kevin Su --- .github/workflows/checks.yml | 22 +++++---- .github/workflows/component_docker_build.yml | 48 ++++++++++++++++++++ 2 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/component_docker_build.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 033eb158e6..9caad8a6cd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -64,6 +64,19 @@ jobs: go-version: ${{ needs.unpack-envvars.outputs.go-version }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + docker-build: + strategy: + fail-fast: false + matrix: + component: + - datacatalog + - flyteadmin + - flytecopilot + - flytepropeller + name: Docker Build Images + uses: ./.github/workflows/component_docker_build.yml + with: + component: ${{ matrix.component }} # TODO(monorepo): these tests are broken. They never test an actual change. # endtoend: @@ -110,12 +123,3 @@ jobs: go-version: ${{ needs.unpack-envvars.outputs.go-version }} secrets: FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} - - build_docker_images: - name: Build Images - uses: ./.github/workflows/publish-images.yml - with: - push: false - secrets: - FLYTE_BOT_PAT: ${{ secrets.FLYTE_BOT_PAT }} - FLYTE_BOT_USERNAME: ${{ secrets.FLYTE_BOT_USERNAME }} diff --git a/.github/workflows/component_docker_build.yml b/.github/workflows/component_docker_build.yml new file mode 100644 index 0000000000..21c22b45d8 --- /dev/null +++ b/.github/workflows/component_docker_build.yml @@ -0,0 +1,48 @@ +name: Build Docker Image + +on: + workflow_call: + inputs: + component: + required: true + type: string + outputs: + cache_key: + description: "Docker Cache key" + value: ${{ jobs.build_docker.outputs.cache_key }} +jobs: + build_docker: + runs-on: ubuntu-latest + outputs: + cache_key: ${{ steps.cache_key.outputs.cache_key }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - id: load-docker-cache + name: Load Docker Cache + uses: actions/cache@v3 + with: + path: /tmp/tmp/docker-images-${{ inputs.component }} + key: /tmp/docker-images-${{ github.run_id }}-${{ inputs.component }} + restore-keys: | + /tmp/docker-images- + - name: Set cache key output + id: cache_key + run: | + echo ::set-output name=cache_key::/tmp/docker-images-${{ github.run_id }} + - name: Prime docker cache + run: (docker load -i /tmp/tmp/docker-images/snapshot-builder.tar || true) && (docker load -i /tmp/tmp/docker-images/snapshot.tar || true) + - name: Build dockerfile + env: + # We are unable to leverage docker buildx here without changing the + # caching mechanism significantly. See here for the caching options + # available for docker buildx: https://docs.docker.com/engine/reference/commandline/buildx_build/#cache-from + # For now at least enable DOCKER_BUILDKIT for faster builds. Eventually we + # should rewrite this pipeline to use docker buildx with cache type=gha. + DOCKER_BUILDKIT: "1" + run: | + docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:builder --target builder --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . + docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:latest --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . + - name: Tag and cache docker image + run: | + mkdir -p /tmp/tmp/docker-images-${{ inputs.component }} && docker save ${{ github.repository_owner }}/${{ inputs.component }}:builder -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-builder-${{ inputs.component }}.tar && docker save ${{ github.repository_owner }}/${{ inputs.component }}:latest -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-${{ inputs.component }}.tar From a67a776f14ebea3533ba10b05e5e767b96b69f65 Mon Sep 17 00:00:00 2001 From: Kevin Su Date: Mon, 6 May 2024 17:24:40 +0800 Subject: [PATCH 3/3] nit Signed-off-by: Kevin Su --- .github/workflows/component_docker_build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/component_docker_build.yml b/.github/workflows/component_docker_build.yml index 21c22b45d8..b4eb882a26 100644 --- a/.github/workflows/component_docker_build.yml +++ b/.github/workflows/component_docker_build.yml @@ -43,6 +43,7 @@ jobs: run: | docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:builder --target builder --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . docker build -t ${{ github.repository_owner }}/${{ inputs.component }}:latest --cache-from=${{ github.repository_owner }}/${{ inputs.component }}:builder --file Dockerfile.${{ inputs.component }} . + - name: Tag and cache docker image run: | mkdir -p /tmp/tmp/docker-images-${{ inputs.component }} && docker save ${{ github.repository_owner }}/${{ inputs.component }}:builder -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-builder-${{ inputs.component }}.tar && docker save ${{ github.repository_owner }}/${{ inputs.component }}:latest -o /tmp/tmp/docker-images-${{ inputs.component }}/snapshot-${{ inputs.component }}.tar