diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index 6d5e12119b3..827946a43dc 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -1,4 +1,4 @@ -name: Docker Build Images +name: Build Docker Images on: push: branches: @@ -8,14 +8,68 @@ on: workflow_dispatch: concurrency: - group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Images (v20+)') + group: format('{0}-{1}', ${{ github.ref }}, 'Build Docker Images') cancel-in-progress: true permissions: read-all jobs: + build_and_push_vttestserver: + name: Build and push vttestserver + runs-on: gh-hosted-runners-16cores-1 + if: github.repository == 'vitessio/vitess' + + strategy: + fail-fast: true + matrix: + branch: [ mysql80 ] + + steps: + - name: Check out code + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Login to Docker Hub + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set Dockerfile path + run: | + echo "DOCKERFILE=./docker/vttestserver/Dockerfile.${{ matrix.branch }}" >> $GITHUB_ENV + + - name: Build and push on main + if: startsWith(github.ref, 'refs/tags/') == false + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: true + tags: vitess/vttestserver:${{ matrix.branch }} + + ###### + # 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 + + - name: Set Docker tag name + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "DOCKER_TAG=vitess/vttestserver:${TAG_NAME}-${{ matrix.branch }}" >> $GITHUB_ENV + + - name: Build and push on tags + if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: true + tags: ${{ env.DOCKER_TAG }} + build_and_push_lite: - name: Build and push vitess/lite Docker images + name: Build and push lite runs-on: ubuntu-latest if: github.repository == 'vitessio/vitess' @@ -26,10 +80,10 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -43,8 +97,8 @@ jobs: fi - name: Build and push on main - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 + if: startsWith(github.ref, 'refs/tags/') == false + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: . file: ${{ env.DOCKERFILE }} @@ -69,7 +123,7 @@ jobs: - name: Build and push on tags if: startsWith(github.ref, 'refs/tags/') - uses: docker/build-push-action@v5 + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: . file: ${{ env.DOCKERFILE }} @@ -77,23 +131,24 @@ jobs: tags: ${{ env.DOCKER_TAG }} build_and_push_components: - name: Build and push vitess components Docker images - needs: build_and_push_lite + name: Build and push runs-on: gh-hosted-runners-16cores-1 - if: github.repository == 'vitessio/vitess' + if: github.repository == 'vitessio/vitess' && needs.build_and_push_lite.result == 'success' + needs: + - build_and_push_lite strategy: fail-fast: true matrix: debian: [ bullseye, bookworm ] - component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, logrotate, logtail, vtbackup, vtexplain ] + component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, vtctldclient, logrotate, logtail, vtbackup, vtexplain ] steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} @@ -103,8 +158,8 @@ jobs: echo "DOCKER_CTX=./docker/binaries/${{ matrix.component }}" >> $GITHUB_ENV - name: Build and push on main latest tag - if: github.ref == 'refs/heads/main' && matrix.debian == 'bookworm' - uses: docker/build-push-action@v5 + if: startsWith(github.ref, 'refs/tags/') == false && matrix.debian == 'bookworm' + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: ${{ env.DOCKER_CTX }} push: true @@ -114,8 +169,8 @@ jobs: DEBIAN_VER=${{ matrix.debian }}-slim - name: Build and push on main debian specific tag - if: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 + if: startsWith(github.ref, 'refs/tags/') == false + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: ${{ env.DOCKER_CTX }} push: true @@ -147,7 +202,7 @@ jobs: # 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 + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: ${{ env.DOCKER_CTX }} push: true @@ -160,11 +215,29 @@ jobs: # 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 + uses: docker/build-push-action@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5.4.0 with: context: ${{ env.DOCKER_CTX }} push: true tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }} build-args: | VT_BASE_VER=${{ env.TAG_NAME }} - DEBIAN_VER=${{ matrix.debian }}-slim \ No newline at end of file + DEBIAN_VER=${{ matrix.debian }}-slim + + slack_notification: + name: Slack Notification if failed + runs-on: ubuntu-latest + needs: + - build_and_push_vttestserver + - build_and_push_lite + - build_and_push_components + if: ${{ failure() }} + steps: + - name: Slack Workflow Notification + uses: Gamesight/slack-workflow-status@68bf00d0dbdbcb206c278399aa1ef6c14f74347a # v1.3.0 + with: + repo_token: ${{secrets.GITHUB_TOKEN}} + slack_webhook_url: ${{secrets.SLACK_WEBHOOK_URL}} + channel: '#docker-build-notifications' + name: 'Docker Build Notification' + icon_url: https://avatars.githubusercontent.com/u/33043890?s=96&v=4 \ No newline at end of file diff --git a/docker/vttestserver/README.md b/docker/vttestserver/README.md new file mode 100644 index 00000000000..1567cf30340 --- /dev/null +++ b/docker/vttestserver/README.md @@ -0,0 +1,17 @@ +## vttestserver docker image + +### How to build manually during a release + +If for whatever reason the automatic build did not happen for `vttestserver` during a release, or if it has failed, +there is a way of building it by hand. Here is how it goes: + +```bash +docker login + +# we first checkout to the git tag of the release we want to build +# we assume in this example that we are releasing v21.0.0-rc1, but replace this by any other tag +git checkout v21.0.0-rc1 + +docker build -f docker/vtttestserver/Dockerfile.mysql80 -t vitess/vttestserver:v21.0.0-rc1-mysql80 . +docker push vitess/vttestserver:v21.0.0-rc1-mysql80 +``` \ No newline at end of file