From 02d3d494e7fbab97c600eeca154f7cded7bc6dc0 Mon Sep 17 00:00:00 2001 From: Victor Payno Date: Sat, 30 Mar 2024 08:30:31 -0700 Subject: [PATCH] ci(docker-build): add step to build base first, then generic and anaconda images --- .github/workflows/docker-build.yml | 49 ++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index c7f55845..30ec934c 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -95,8 +95,44 @@ jobs: # Set the output named "docs_changed" printf "%s=%s\n" "docs_changed" "${HAS_DIFF}" >> "${GITHUB_OUTPUT}" - stage2: - name: Docker Build + stage2a: + name: Docker Build Base Image + strategy: + matrix: + os: ["ubuntu-latest"] + image: + - ci-base-debian + runs-on: "${{ matrix.os }}" + needs: [stage1] + if: needs.stage1.outputs.docs_changed == 'True' + outputs: + tag_date: ${{ steps.setup_image_info.outputs.tag_date }} + steps: + - name: Setup Env [${{ matrix.os }} - ${{ matrix.image }}] + id: setup_image_info + run: |- + tag_date="$(date +%Y%m%d)" + printf "%s=%s\n" "tag_date" "${tag_date}" >> "${GITHUB_OUTPUT}" + - name: Docker Build Checkout [${{ matrix.os }} - ${{ matrix.image }}] + uses: actions/checkout@v3 + - name: Login to Docker Hub [${{ matrix.os }} - ${{ matrix.image }}] + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Set up Docker Buildx [${{ matrix.os }} - ${{ matrix.image }}] + uses: docker/setup-buildx-action@v2 + - name: Build and push [${{ matrix.os }} - ${{ matrix.image }}] + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ steps.setup_image_info.outputs.tag_date }} + target: ${{ matrix.image }} + cache-to: type=gha + stage2b: + name: Docker Build CI Images strategy: matrix: os: ["ubuntu-latest"] @@ -104,7 +140,7 @@ jobs: - ci-generic-debian - ci-anaconda-debian runs-on: "${{ matrix.os }}" - needs: [stage1] + needs: [stage1, stage2a] if: needs.stage1.outputs.docs_changed == 'True' outputs: tag_date: ${{ steps.setup_image_info.outputs.tag_date }} @@ -131,6 +167,7 @@ jobs: push: true tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest,${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:${{ steps.setup_image_info.outputs.tag_date }} target: ${{ matrix.image }} + cache-from: type=gha stage3: name: Docker Build Check env: @@ -139,12 +176,12 @@ jobs: matrix: os: - vpayno/ci-generic-debian:latest - - vpayno/ci-generic-debian:${{ needs.stage2.outputs.tag_date }} + - vpayno/ci-generic-debian:${{ needs.stage2b.outputs.tag_date }} - vpayno/ci-anaconda-debian:latest - - vpayno/ci-anaconda-debian:${{ needs.stage2.outputs.tag_date }} + - vpayno/ci-anaconda-debian:${{ needs.stage2b.outputs.tag_date }} runs-on: ubuntu-latest container: ${{ matrix.os }} - needs: [stage2] + needs: [stage2b] steps: - name: Test New Container [${{ matrix.os }}] run: |-