From 17e9453048583faa572fc96f5fb58c9c3d807cde Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 4 Jul 2024 12:19:30 -0400 Subject: [PATCH 01/10] Remove bootstrap dependency for the lite image Signed-off-by: Florent Poinsard --- docker/lite/Dockerfile | 25 +++++++++++-------------- docker/lite/Dockerfile.percona80 | 24 +++++++++++------------- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/docker/lite/Dockerfile b/docker/lite/Dockerfile index fd01f7d9ef6..7c0b22aed3c 100644 --- a/docker/lite/Dockerfile +++ b/docker/lite/Dockerfile @@ -12,29 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -# NOTE: We have to build the Vitess binaries from scratch instead of sharing -# a base image because Docker Hub dropped the feature we relied upon to -# ensure images contain the right binaries. - -# Use a temporary layer for the build stage. -ARG bootstrap_version=34 -ARG image="vitess/bootstrap:${bootstrap_version}-mysql80" - -FROM "${image}" AS builder +FROM --platform=linux/amd64 golang:1.22.5-bullseye AS builder # Allows docker builds to set the BUILD_NUMBER ARG BUILD_NUMBER -# Re-copy sources from working tree. -COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess +WORKDIR /vt/src/vitess.io/vitess -# Build and install Vitess in a temporary output directory. +# Create vitess user +RUN groupadd -r vitess && useradd -r -g vitess vitess +RUN mkdir -p /vt/vtdataroot /home/vitess +RUN chown -R vitess:vitess /vt /home/vitess USER vitess +# Re-copy sources from working tree. +COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess + RUN make install PREFIX=/vt/install # Start over and build the final image. -FROM debian:bullseye-slim +FROM --platform=linux/amd64 debian:bullseye-slim # Install dependencies COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh @@ -45,7 +42,7 @@ RUN groupadd -r vitess && useradd -r -g vitess vitess RUN mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTROOT /vt/src/vitess.io/vitess +ENV VTROOT /vt ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH diff --git a/docker/lite/Dockerfile.percona80 b/docker/lite/Dockerfile.percona80 index 1e27f45e692..cded55438ec 100644 --- a/docker/lite/Dockerfile.percona80 +++ b/docker/lite/Dockerfile.percona80 @@ -12,28 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -# NOTE: We have to build the Vitess binaries from scratch instead of sharing -# a base image because Docker Hub dropped the feature we relied upon to -# ensure images contain the right binaries. - -# Use a temporary layer for the build stage. -ARG bootstrap_version=34 -ARG image="vitess/bootstrap:${bootstrap_version}-percona80" - -FROM "${image}" AS builder +FROM --platform=linux/amd64 golang:1.22.5-bullseye AS builder # Allows docker builds to set the BUILD_NUMBER ARG BUILD_NUMBER +WORKDIR /vt/src/vitess.io/vitess + +# Create vitess user +RUN groupadd -r vitess && useradd -r -g vitess vitess +RUN mkdir -p /vt/vtdataroot /home/vitess +RUN chown -R vitess:vitess /vt /home/vitess +USER vitess + # Re-copy sources from working tree. COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess -# Build and install Vitess in a temporary output directory. -USER vitess RUN make install PREFIX=/vt/install # Start over and build the final image. -FROM debian:bullseye-slim +FROM --platform=linux/amd64 debian:bullseye-slim # Install dependencies COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh @@ -44,7 +42,7 @@ RUN groupadd -r vitess && useradd -r -g vitess vitess RUN mkdir -p /vt/vtdataroot && chown -R vitess:vitess /vt # Set up Vitess environment (just enough to run pre-built Go binaries) -ENV VTROOT /vt/src/vitess.io/vitess +ENV VTROOT /vt ENV VTDATAROOT /vt/vtdataroot ENV PATH $VTROOT/bin:$PATH From 7dcf64bf372b4265628f44cbf6d8a6841df43e3e Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 4 Jul 2024 12:24:33 -0400 Subject: [PATCH 02/10] Remove the local docker image Signed-off-by: Florent Poinsard --- docker/local/Dockerfile | 45 ---------------------- docker/local/install_local_dependencies.sh | 25 ------------ docker/local/run.sh | 3 -- go/tools/go-upgrade/go-upgrade.go | 2 - 4 files changed, 75 deletions(-) delete mode 100644 docker/local/Dockerfile delete mode 100755 docker/local/install_local_dependencies.sh delete mode 100755 docker/local/run.sh diff --git a/docker/local/Dockerfile b/docker/local/Dockerfile deleted file mode 100644 index 5e9d4aed326..00000000000 --- a/docker/local/Dockerfile +++ /dev/null @@ -1,45 +0,0 @@ -ARG bootstrap_version=34 -ARG image="vitess/bootstrap:${bootstrap_version}-common" - -FROM "${image}" - -RUN apt-get update -RUN apt-get install -y sudo curl vim jq - -# Install dependencies -COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh -RUN /vt/dist/install_dependencies.sh mysql80 - -COPY docker/local/install_local_dependencies.sh /vt/dist/install_local_dependencies.sh -RUN /vt/dist/install_local_dependencies.sh -RUN echo "source /vt/common/env.sh" >> /etc/bash.bashrc - -# Allows some docker builds to disable CGO -ARG CGO_ENABLED=0 - -# Re-copy sources from working tree. -COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess - -# Build and install Vitess in a temporary output directory. -USER vitess - -WORKDIR /vt/src/vitess.io/vitess -RUN make install PREFIX=/vt/install - -ENV VTROOT /vt/src/vitess.io/vitess -ENV VTDATAROOT /vt/vtdataroot -ENV PATH $VTROOT/bin:$PATH -ENV PATH="/var/opt/etcd:${PATH}" - -RUN mkdir /vt/local -COPY examples/local /vt/local - -# Copy the vtadmin web app to the correct location and npm install -COPY --chown=vitess:vitess web /web -RUN npm install /web/vtadmin -RUN /web/vtadmin/build.sh - -RUN mkdir /vt/common -COPY examples/common /vt/common - -CMD cd /vt/local && ./101_initial_cluster.sh && /bin/bash diff --git a/docker/local/install_local_dependencies.sh b/docker/local/install_local_dependencies.sh deleted file mode 100755 index 07fd302e283..00000000000 --- a/docker/local/install_local_dependencies.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# This is a script that gets run as part of the Dockerfile build -# to install dependencies for the vitess/mini image. -# -# Usage: install_local_dependencies.sh - -set -euo pipefail - -# Install etcd -ETCD_VER=v3.4.9 -DOWNLOAD_URL=https://storage.googleapis.com/etcd - -curl -k -L ${DOWNLOAD_URL}/${ETCD_VER}/etcd-${ETCD_VER}-linux-amd64.tar.gz -o /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -mkdir -p /var/opt/etcd -sudo tar xzvf /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz -C /var/opt/etcd --strip-components=1 -rm -f /tmp/etcd-${ETCD_VER}-linux-amd64.tar.gz - -mkdir -p /var/run/etcd && chown -R vitess:vitess /var/run/etcd - -# Clean up files we won't need in the final image. -rm -rf /var/lib/apt/lists/* - -# Install npm and node dependencies for vtadmin -curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs diff --git a/docker/local/run.sh b/docker/local/run.sh deleted file mode 100755 index 16b07fc426c..00000000000 --- a/docker/local/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -docker run -d -p 14200:14200 -p 14201:14201 -p 15000:15000 -p 15001:15001 -p 15991:15991 -p 15999:15999 -p 16000:16000 --rm -it vitess/local diff --git a/go/tools/go-upgrade/go-upgrade.go b/go/tools/go-upgrade/go-upgrade.go index ee42040e5c0..dbec922d578 100644 --- a/go/tools/go-upgrade/go-upgrade.go +++ b/go/tools/go-upgrade/go-upgrade.go @@ -435,8 +435,6 @@ func updateBootstrapVersionInCodebase(old, new string, newGoVersion *version.Ver return nil } files, err := getListOfFilesInPaths([]string{ - "./docker/lite", - "./docker/local", "./docker/vttestserver", "./Makefile", "./test/templates", From 1ab2da3aa170058121eaa5581b0c82e70494be5a Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Thu, 4 Jul 2024 12:46:20 -0400 Subject: [PATCH 03/10] Remove bootstrap dependency for the vttestserver image Signed-off-by: Florent Poinsard --- Makefile | 2 +- docker/vttestserver/Dockerfile.mysql80 | 22 ++++++++++------------ go/tools/go-upgrade/go-upgrade.go | 4 +++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index f0b9038a769..e46f5d1ca5a 100644 --- a/Makefile +++ b/Makefile @@ -334,7 +334,7 @@ docker_lite: docker_mini: ${call build_docker_image,docker/mini/Dockerfile,vitess/mini} -DOCKER_VTTESTSERVER_SUFFIX = mysql57 mysql80 +DOCKER_VTTESTSERVER_SUFFIX = mysql80 DOCKER_VTTESTSERVER_TARGETS = $(addprefix docker_vttestserver_,$(DOCKER_VTTESTSERVER_SUFFIX)) $(DOCKER_VTTESTSERVER_TARGETS): docker_vttestserver_%: ${call build_docker_image,docker/vttestserver/Dockerfile.$*,vitess/vttestserver:$*} diff --git a/docker/vttestserver/Dockerfile.mysql80 b/docker/vttestserver/Dockerfile.mysql80 index d6b0a200fa7..2e79d389c7d 100644 --- a/docker/vttestserver/Dockerfile.mysql80 +++ b/docker/vttestserver/Dockerfile.mysql80 @@ -12,28 +12,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -# NOTE: We have to build the Vitess binaries from scratch instead of sharing -# a base image because Docker Hub dropped the feature we relied upon to -# ensure images contain the right binaries. - -# Use a temporary layer for the build stage. -ARG bootstrap_version=34 -ARG image="vitess/bootstrap:${bootstrap_version}-mysql80" - -FROM "${image}" AS builder +FROM --platform=linux/amd64 golang:1.22.5-bullseye AS builder # Allows docker builds to set the BUILD_NUMBER ARG BUILD_NUMBER +WORKDIR /vt/src/vitess.io/vitess + +# Create vitess user +RUN groupadd -r vitess && useradd -r -g vitess vitess +RUN mkdir -p /vt/vtdataroot /home/vitess +RUN chown -R vitess:vitess /vt /home/vitess +USER vitess + # Re-copy sources from working tree. COPY --chown=vitess:vitess . /vt/src/vitess.io/vitess -# Build and install Vitess in a temporary output directory. -USER vitess RUN make install-testing PREFIX=/vt/install # Start over and build the final image. -FROM debian:bullseye-slim +FROM --platform=linux/amd64 debian:bullseye-slim # Install dependencies COPY docker/utils/install_dependencies.sh /vt/dist/install_dependencies.sh diff --git a/go/tools/go-upgrade/go-upgrade.go b/go/tools/go-upgrade/go-upgrade.go index dbec922d578..34543120202 100644 --- a/go/tools/go-upgrade/go-upgrade.go +++ b/go/tools/go-upgrade/go-upgrade.go @@ -393,6 +393,9 @@ func replaceGoVersionInCodebase(old, new *version.Version, workflowUpdate bool) "./test/templates", "./build.env", "./docker/bootstrap/Dockerfile.common", + "./docker/lite/Dockerfile", + "./docker/lite/Dockerfile.percona80", + "./docker/vttestserver/Dockerfile.mysql80", } if workflowUpdate { explore = append(explore, "./.github/workflows") @@ -435,7 +438,6 @@ func updateBootstrapVersionInCodebase(old, new string, newGoVersion *version.Ver return nil } files, err := getListOfFilesInPaths([]string{ - "./docker/vttestserver", "./Makefile", "./test/templates", }) From 0a4826eb8c869bc01368f301068a1acfc33dd4f3 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 8 Jul 2024 12:43:24 -0400 Subject: [PATCH 04/10] add dry-run docker build for all general images Signed-off-by: Florent Poinsard --- .github/workflows/docker_build_images.yml | 33 ++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index a923b7f57c3..7bb77563964 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -1,5 +1,6 @@ name: Docker Build Images on: + pull_request: push: branches: - main @@ -24,6 +25,16 @@ jobs: branch: [ latest, percona80 ] steps: + - name: Define if we want to push the images + id: skip-push + run: | + push='false' + if [[ "${{github.event.pull_request}}" == "" ]]; then + push='true' + fi + echo Push ${skip} + echo "skip-push=${push}" >> $GITHUB_OUTPUT + - name: Check out code uses: actions/checkout@v4 @@ -42,12 +53,12 @@ jobs: fi - name: Build and push on main - if: github.ref == 'refs/heads/main' + if: startsWith(github.ref, 'refs/tags/') == false uses: docker/build-push-action@v5 with: context: . file: ${{ env.DOCKERFILE }} - push: true + push: ${{ steps.skip-push.outputs.skip-push }} tags: vitess/lite:${{ matrix.branch }} ###### @@ -88,6 +99,16 @@ jobs: component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, vtctldclient, logrotate, logtail, vtbackup, vtexplain ] steps: + - name: Define if we want to push the images + id: skip-push + run: | + push='false' + if [[ "${{github.event.pull_request}}" == "" ]]; then + push='true' + fi + echo Push ${skip} + echo "skip-push=${push}" >> $GITHUB_OUTPUT + - name: Check out code uses: actions/checkout@v4 @@ -102,22 +123,22 @@ 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' + if: startsWith(github.ref, 'refs/tags/') == false && matrix.debian == 'bookworm' uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: true + push: ${{ steps.skip-push.outputs.skip-push }} tags: vitess/${{ matrix.component }}:latest build-args: | VT_BASE_VER=latest DEBIAN_VER=${{ matrix.debian }}-slim - name: Build and push on main debian specific tag - if: github.ref == 'refs/heads/main' + if: startsWith(github.ref, 'refs/tags/') == false uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: true + push: ${{ steps.skip-push.outputs.skip-push }} tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }} build-args: | VT_BASE_VER=latest From aefb69498691c656b35febf0485d923b222ec0a5 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 8 Jul 2024 12:50:17 -0400 Subject: [PATCH 05/10] login only when we need to push the images Signed-off-by: Florent Poinsard --- .github/workflows/docker_build_images.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index 7bb77563964..e141b5a9803 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -39,6 +39,7 @@ jobs: uses: actions/checkout@v4 - name: Login to Docker Hub + if: steps.skip-push.outputs.skip-push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -113,6 +114,7 @@ jobs: uses: actions/checkout@v4 - name: Login to Docker Hub + if: steps.skip-push.outputs.skip-push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} From 6c1158d161564cbcc5ed3d48b0b90807133cd802 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 8 Jul 2024 13:09:40 -0400 Subject: [PATCH 06/10] Merge all the worklow that builds into a single one Signed-off-by: Florent Poinsard --- .github/workflows/docker_build_images.yml | 120 +++++++++++++----- .../workflows/docker_build_vttestserver.yml | 65 ---------- 2 files changed, 90 insertions(+), 95 deletions(-) delete mode 100644 .github/workflows/docker_build_vttestserver.yml diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index e141b5a9803..0bc0faf580f 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -5,41 +5,109 @@ on: branches: - main tags: - - 'v[2-9][0-9]*.*' # run only on tags greater or equal to v20.0.0 where this new way of building docker image was changed + - '*' concurrency: - group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Images (v20+)') + group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Images') cancel-in-progress: true permissions: read-all jobs: - build_and_push_lite: - name: Build and push vitess/lite Docker images - runs-on: gh-hosted-runners-16cores-1 + skip_push: + name: Set skip_push if we are on a Pull Request + runs-on: ubuntu-20.04 if: github.repository == 'vitessio/vitess' - - strategy: - fail-fast: true - matrix: - branch: [ latest, percona80 ] + outputs: + skip_push: ${{ steps.skip_push.outputs.skip_push }} steps: - - name: Define if we want to push the images - id: skip-push + - name: Set skip_push + id: skip_push run: | push='false' if [[ "${{github.event.pull_request}}" == "" ]]; then push='true' fi echo Push ${skip} - echo "skip-push=${push}" >> $GITHUB_OUTPUT + echo "skip_push=${push}" >> $GITHUB_OUTPUT + + build_and_push_vttestserver: + name: Build and push vitess/vttestserver Docker images + runs-on: gh-hosted-runners-16cores-1 + if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' + needs: + - skip_push + strategy: + fail-fast: true + matrix: + branch: [ mysql80 ] + + steps: - name: Check out code uses: actions/checkout@v4 - name: Login to Docker Hub - if: steps.skip-push.outputs.skip-push == 'true' + if: needs.skip_push.outputs.skip_push == 'true' + uses: docker/login-action@v3 + 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@v5 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: ${{ needs.skip_push.outputs.skip_push }} + 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@v5 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: true + tags: ${{ env.DOCKER_TAG }} + + + build_and_push_lite: + name: Build and push vitess/lite Docker images + runs-on: gh-hosted-runners-16cores-1 + if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' + needs: + - skip_push + + strategy: + fail-fast: true + matrix: + branch: [ latest, percona80 ] + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Login to Docker Hub + if: needs.skip_push.outputs.skip_push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -59,7 +127,7 @@ jobs: with: context: . file: ${{ env.DOCKERFILE }} - push: ${{ steps.skip-push.outputs.skip-push }} + push: ${{ needs.skip_push.outputs.skip_push }} tags: vitess/lite:${{ matrix.branch }} ###### @@ -89,9 +157,11 @@ jobs: build_and_push_components: name: Build and push vitess components Docker images - needs: build_and_push_lite runs-on: gh-hosted-runners-16cores-1 - if: github.repository == 'vitessio/vitess' + if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' && needs.build_and_push_lite.result == 'success' + needs: + - skip_push + - build_and_push_lite strategy: fail-fast: true @@ -100,21 +170,11 @@ jobs: component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, vtctldclient, logrotate, logtail, vtbackup, vtexplain ] steps: - - name: Define if we want to push the images - id: skip-push - run: | - push='false' - if [[ "${{github.event.pull_request}}" == "" ]]; then - push='true' - fi - echo Push ${skip} - echo "skip-push=${push}" >> $GITHUB_OUTPUT - - name: Check out code uses: actions/checkout@v4 - name: Login to Docker Hub - if: steps.skip-push.outputs.skip-push == 'true' + if: needs.skip_push.outputs.skip_push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -129,7 +189,7 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: ${{ steps.skip-push.outputs.skip-push }} + push: ${{ needs.skip_push.outputs.skip_push }} tags: vitess/${{ matrix.component }}:latest build-args: | VT_BASE_VER=latest @@ -140,7 +200,7 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: ${{ steps.skip-push.outputs.skip-push }} + push: ${{ needs.skip_push.outputs.skip_push }} tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }} build-args: | VT_BASE_VER=latest diff --git a/.github/workflows/docker_build_vttestserver.yml b/.github/workflows/docker_build_vttestserver.yml deleted file mode 100644 index 1d157eef921..00000000000 --- a/.github/workflows/docker_build_vttestserver.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Docker Build vttestserver -on: - push: - branches: - - main - tags: - - '*' - -concurrency: - group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build vttestserver') - cancel-in-progress: true - -permissions: read-all - -jobs: - build_and_push: - name: Build and push vitess/vttestserver Docker images - 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@v4 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - 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: github.ref == 'refs/heads/main' - uses: docker/build-push-action@v5 - with: - context: . - file: ${{ env.DOCKERFILE }} - push: true - tags: vitess/vttestserver:${{ matrix.branch }} - - - 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@v5 - with: - context: . - file: ${{ env.DOCKERFILE }} - push: true - tags: ${{ env.DOCKER_TAG }} From 72d9cd538e9552f28ed70ffecb24b1a1741cb33d Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 8 Jul 2024 14:24:58 -0400 Subject: [PATCH 07/10] Fix variable name in debug log Signed-off-by: Florent Poinsard --- .github/workflows/docker_build_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index 0bc0faf580f..9ae1fb44b4b 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -29,7 +29,7 @@ jobs: if [[ "${{github.event.pull_request}}" == "" ]]; then push='true' fi - echo Push ${skip} + echo Push='${push}' echo "skip_push=${push}" >> $GITHUB_OUTPUT build_and_push_vttestserver: From af52626c268ca30ba9a501795d01e25bc53d1b7a Mon Sep 17 00:00:00 2001 From: Florent Poinsard <35779988+frouioui@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:31:46 -0400 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Deepthi Sigireddi Signed-off-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com> --- .github/workflows/docker_build_images.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index 9ae1fb44b4b..0349bb1b5d0 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: pull_request: push: @@ -33,7 +33,7 @@ jobs: echo "skip_push=${push}" >> $GITHUB_OUTPUT build_and_push_vttestserver: - name: Build and push vitess/vttestserver Docker images + name: Build and push vttestserver runs-on: gh-hosted-runners-16cores-1 if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' needs: @@ -91,7 +91,7 @@ jobs: build_and_push_lite: - name: Build and push vitess/lite Docker images + name: Build and push vitess/lite runs-on: gh-hosted-runners-16cores-1 if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' needs: @@ -156,7 +156,7 @@ jobs: tags: ${{ env.DOCKER_TAG }} build_and_push_components: - name: Build and push vitess components Docker images + name: Build and push runs-on: gh-hosted-runners-16cores-1 if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' && needs.build_and_push_lite.result == 'success' needs: From c5ae3ee8a02236376aff895e9beae6675449f058 Mon Sep 17 00:00:00 2001 From: Florent Poinsard <35779988+frouioui@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:51:16 -0400 Subject: [PATCH 09/10] Apply suggestions from code review Signed-off-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com> --- .github/workflows/docker_build_images.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/docker_build_images.yml index 0349bb1b5d0..243f417f027 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/docker_build_images.yml @@ -8,7 +8,7 @@ on: - '*' concurrency: - group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Images') + group: format('{0}-{1}', ${{ github.ref }}, 'Build Docker Images') cancel-in-progress: true permissions: read-all @@ -91,7 +91,7 @@ jobs: build_and_push_lite: - name: Build and push vitess/lite + name: Build and push lite runs-on: gh-hosted-runners-16cores-1 if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' needs: From e99c1a762271fe3b4935f24637a0829d2e106990 Mon Sep 17 00:00:00 2001 From: Florent Poinsard Date: Mon, 8 Jul 2024 15:17:43 -0400 Subject: [PATCH 10/10] Apply review suggestions Signed-off-by: Florent Poinsard --- ...ild_images.yml => build_docker_images.yml} | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) rename .github/workflows/{docker_build_images.yml => build_docker_images.yml} (88%) diff --git a/.github/workflows/docker_build_images.yml b/.github/workflows/build_docker_images.yml similarity index 88% rename from .github/workflows/docker_build_images.yml rename to .github/workflows/build_docker_images.yml index 243f417f027..0daada540b8 100644 --- a/.github/workflows/docker_build_images.yml +++ b/.github/workflows/build_docker_images.yml @@ -14,30 +14,30 @@ concurrency: permissions: read-all jobs: - skip_push: - name: Set skip_push if we are on a Pull Request + push: + name: Set push variable runs-on: ubuntu-20.04 if: github.repository == 'vitessio/vitess' outputs: - skip_push: ${{ steps.skip_push.outputs.skip_push }} + push: ${{ steps.push.outputs.push }} steps: - - name: Set skip_push - id: skip_push + - name: Set push variable + id: push run: | push='false' if [[ "${{github.event.pull_request}}" == "" ]]; then push='true' fi echo Push='${push}' - echo "skip_push=${push}" >> $GITHUB_OUTPUT + echo "push=${push}" >> $GITHUB_OUTPUT build_and_push_vttestserver: name: Build and push vttestserver runs-on: gh-hosted-runners-16cores-1 - if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' + if: github.repository == 'vitessio/vitess' && needs.push.result == 'success' needs: - - skip_push + - push strategy: fail-fast: true @@ -49,7 +49,7 @@ jobs: uses: actions/checkout@v4 - name: Login to Docker Hub - if: needs.skip_push.outputs.skip_push == 'true' + if: needs.push.outputs.push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -65,7 +65,7 @@ jobs: with: context: . file: ${{ env.DOCKERFILE }} - push: ${{ needs.skip_push.outputs.skip_push }} + push: ${{ needs.push.outputs.push }} tags: vitess/vttestserver:${{ matrix.branch }} ###### @@ -93,9 +93,9 @@ jobs: build_and_push_lite: name: Build and push lite runs-on: gh-hosted-runners-16cores-1 - if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' + if: github.repository == 'vitessio/vitess' && needs.push.result == 'success' needs: - - skip_push + - push strategy: fail-fast: true @@ -107,7 +107,7 @@ jobs: uses: actions/checkout@v4 - name: Login to Docker Hub - if: needs.skip_push.outputs.skip_push == 'true' + if: needs.push.outputs.push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -127,7 +127,7 @@ jobs: with: context: . file: ${{ env.DOCKERFILE }} - push: ${{ needs.skip_push.outputs.skip_push }} + push: ${{ needs.push.outputs.push }} tags: vitess/lite:${{ matrix.branch }} ###### @@ -158,9 +158,9 @@ jobs: build_and_push_components: name: Build and push runs-on: gh-hosted-runners-16cores-1 - if: github.repository == 'vitessio/vitess' && needs.skip_push.result == 'success' && needs.build_and_push_lite.result == 'success' + if: github.repository == 'vitessio/vitess' && needs.push.result == 'success' && needs.build_and_push_lite.result == 'success' needs: - - skip_push + - push - build_and_push_lite strategy: @@ -174,7 +174,7 @@ jobs: uses: actions/checkout@v4 - name: Login to Docker Hub - if: needs.skip_push.outputs.skip_push == 'true' + if: needs.push.outputs.push == 'true' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -189,7 +189,7 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: ${{ needs.skip_push.outputs.skip_push }} + push: ${{ needs.push.outputs.push }} tags: vitess/${{ matrix.component }}:latest build-args: | VT_BASE_VER=latest @@ -200,7 +200,7 @@ jobs: uses: docker/build-push-action@v5 with: context: ${{ env.DOCKER_CTX }} - push: ${{ needs.skip_push.outputs.skip_push }} + push: ${{ needs.push.outputs.push }} tags: vitess/${{ matrix.component }}:latest-${{ matrix.debian }} build-args: | VT_BASE_VER=latest