diff --git a/.github/workflows/docker_build_base.yml b/.github/workflows/docker_build_base.yml index ec917f8ff8f..d77ab33d7df 100644 --- a/.github/workflows/docker_build_base.yml +++ b/.github/workflows/docker_build_base.yml @@ -15,7 +15,7 @@ permissions: read-all jobs: build_and_push_base: name: Build and push vitess/base Docker images - runs-on: ubuntu-latest + runs-on: ubuntu-latest # TODO: use larger runner when testing is done # if: github.repository == 'vitessio/vitess' strategy: @@ -68,4 +68,81 @@ jobs: context: . file: ${{ env.DOCKERFILE }} push: true - tags: ${{ env.DOCKER_TAG }} \ No newline at end of file + tags: ${{ env.DOCKER_TAG }} + + + build_and_push_components: + name: Build and push vitess components Docker images + runs-on: ubuntu-latest # TODO: use larger runner when testing is done + # if: github.repository == 'vitessio/vitess' + + strategy: + fail-fast: true + matrix: + debian: [ bullseye, bookworm ] + component: [ k8s, vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, logrotate, logtail ] + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + # Build and Push component image to tag "latest" if branch=main and debian=bookworm + - name: Build and push on main Bookworm (default) + if: github.ref == 'refs/heads/main' && matrix.debian == 'bookworm' + uses: docker/build-push-action@v5 + with: + context: docker/${{ matrix.component }} + push: true + tags: frouioui/${{ matrix.component }}:latest + + # Build and Push component image to tag "latest-bullseye" if branch=main and debian=bullseye + - name: Build and push on main Bullseye + if: github.ref == 'refs/heads/main' && matrix.debian == 'bullseye' + uses: docker/build-push-action@v5 + with: + context: docker/${{ matrix.component }} + push: true + tags: frouioui/${{ matrix.component }}:latest-bullseye + + ###### + # All code below only applies to new tags + ###### + + - name: Get the Git tag + if: startsWith(github.ref, 'refs/tags/') + run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + + # We push git-tag-based images to three tags, i.e. for 'v19.0.0' we push to: + # vitess/${{ matrix.component }}:v19.0.0 + # vitess/${{ matrix.component }}:v19.0.0-bookworm + # vitess/${{ matrix.component }}:v19.0.0-bullseye + - name: Set Docker tag name + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "DOCKER_TAG=frouioui/${{ matrix.component }}:${TAG_NAME}-${{ matrix.debian }}" >> $GITHUB_ENV + echo "DOCKER_TAG_DEFAULT_DEBIAN=frouioui/${{ matrix.component }}:${TAG_NAME}" >> $GITHUB_ENV + + # Build and Push component image to DOCKER_TAG, applies to both debian version + - name: Build and push on tags using Debian extension + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v5 + with: + context: docker/${{ matrix.component }} + push: true + tags: ${{ env.DOCKER_TAG }} + + # Build and Push component image to DOCKER_TAG_DEFAULT_DEBIAN, only applies when building the default Debian version (bookworm) + # It is fine to build a second time here when "matrix.debian == 'bookworm'" as we have cached the first build already + - name: Build and push on tags without Debian extension + if: startsWith(github.ref, 'refs/tags/') && matrix.debian == 'bookworm' + uses: docker/build-push-action@v5 + with: + context: docker/${{ matrix.component }} + push: true + tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }} \ No newline at end of file