From 35a6901a73652de49cfb532c0cf3352acee803f9 Mon Sep 17 00:00:00 2001 From: Florent Poinsard <35779988+frouioui@users.noreply.github.com> Date: Tue, 17 Oct 2023 19:42:36 -0500 Subject: [PATCH] build and push on frouioui for testing (#89) --- .github/workflows/docker_build_base.yml | 261 ++++++++++++++++++++++++ .github/workflows/docker_build_lite.yml | 2 +- docker/k8s/Dockerfile | 2 +- docker/k8s/mysqlctl/Dockerfile | 2 +- docker/k8s/mysqlctld/Dockerfile | 2 +- docker/k8s/vtadmin/Dockerfile | 2 +- docker/k8s/vtbackup/Dockerfile | 2 +- docker/k8s/vtctl/Dockerfile | 2 +- docker/k8s/vtctlclient/Dockerfile | 2 +- docker/k8s/vtctld/Dockerfile | 2 +- docker/k8s/vtgate/Dockerfile | 2 +- docker/k8s/vtorc/Dockerfile | 2 +- docker/k8s/vttablet/Dockerfile | 2 +- 13 files changed, 273 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/docker_build_base.yml diff --git a/.github/workflows/docker_build_base.yml b/.github/workflows/docker_build_base.yml new file mode 100644 index 00000000000..030698c4205 --- /dev/null +++ b/.github/workflows/docker_build_base.yml @@ -0,0 +1,261 @@ +name: Docker Build Base +on: + push: + branches: + - main + tags: + - '*' + +concurrency: + group: format('{0}-{1}', ${{ github.ref }}, 'Docker Build Base') + cancel-in-progress: true + +permissions: read-all + +jobs: + build_and_push_base: + name: Build and push vitess/base Docker images + runs-on: ubuntu-latest # TODO: use larger runner when testing is done +# if: github.repository == 'vitessio/vitess' + + strategy: + fail-fast: true + matrix: + branch: [ latest, mysql57, percona57, percona80 ] + + 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 }} + + - name: Set Dockerfile path + run: | + if [[ "${{ matrix.branch }}" == "latest" ]]; then + echo "DOCKERFILE=./docker/base/Dockerfile" >> $GITHUB_ENV + else + echo "DOCKERFILE=./docker/base/Dockerfile.${{ matrix.branch }}" >> $GITHUB_ENV + fi + + - 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: frouioui/base:${{ 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/') && matrix.branch == 'latest' + run: | + if [[ "${{ matrix.branch }}" == "latest" ]]; then + echo "DOCKER_TAG=frouioui/base:${TAG_NAME}" >> $GITHUB_ENV + fi + + - name: Build and push on tags + if: startsWith(github.ref, 'refs/tags/') && matrix.branch == 'latest' + uses: docker/build-push-action@v5 + with: + context: . + file: ${{ env.DOCKERFILE }} + push: true + tags: ${{ env.DOCKER_TAG }} + + build_and_push_k8s: + needs: build_and_push_base + name: Build and push vitess/k8s image + 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 ] + + 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 }} + + - name: Set Docker context path + run: | + echo "DOCKER_CTX=./docker/k8s" >> $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 + with: + context: ${{ env.DOCKER_CTX }} + push: true + tags: frouioui/k8s: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' + uses: docker/build-push-action@v5 + with: + context: ${{ env.DOCKER_CTX }} + push: true + tags: frouioui/k8s:latest-${{ matrix.debian }} + build-args: | + VT_BASE_VER=latest + DEBIAN_VER=${{ matrix.debian }}-slim + + ###### + # 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 k8s image to three tags, i.e. for 'v19.0.0' we push to: + # + # vitess/k8s:v19.0.0 (DOCKER_TAG_DEFAULT_DEBIAN) + # vitess/k8s:v19.0.0-bookworm (DOCKER_TAG) + # vitess/k8s:v19.0.0-bullseye (DOCKER_TAG) + # + - name: Set Docker tag name + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "DOCKER_TAG_DEFAULT_DEBIAN=frouioui/k8s:${TAG_NAME}" >> $GITHUB_ENV + echo "DOCKER_TAG=frouioui/k8s:${TAG_NAME}-${{ matrix.debian }}" >> $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: ${{ env.DOCKER_CTX }} + push: true + tags: ${{ env.DOCKER_TAG }} + build-args: | + VT_BASE_VER=${TAG_NAME} + DEBIAN_VER=${{ matrix.debian }}-slim + + # 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: ${{ env.DOCKER_CTX }} + push: true + tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }} + build-args: | + VT_BASE_VER=${TAG_NAME} + DEBIAN_VER=${{ matrix.debian }}-slim + + + build_and_push_components: + needs: build_and_push_k8s + 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: [ 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 }} + + - name: Set Docker context path + run: | + echo "DOCKER_CTX=./docker/k8s/${{ 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 + with: + context: ${{ env.DOCKER_CTX }} + push: true + tags: frouioui/${{ 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' + uses: docker/build-push-action@v5 + with: + context: ${{ env.DOCKER_CTX }} + push: true + tags: frouioui/${{ matrix.component }}:latest-${{ matrix.debian }} + build-args: | + VT_BASE_VER=latest + DEBIAN_VER=${{ matrix.debian }}-slim + + ###### + # 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 (DOCKER_TAG_DEFAULT_DEBIAN) + # vitess/${{ matrix.component }}:v19.0.0-bookworm (DOCKER_TAG) + # vitess/${{ matrix.component }}:v19.0.0-bullseye (DOCKER_TAG) + # + - name: Set Docker tag name + if: startsWith(github.ref, 'refs/tags/') + run: | + echo "DOCKER_TAG_DEFAULT_DEBIAN=frouioui/${{ matrix.component }}:${TAG_NAME}" >> $GITHUB_ENV + echo "DOCKER_TAG=frouioui/${{ matrix.component }}:${TAG_NAME}-${{ matrix.debian }}" >> $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: ${{ env.DOCKER_CTX }} + push: true + tags: ${{ env.DOCKER_TAG }} + build-args: | + VT_BASE_VER=${TAG_NAME} + DEBIAN_VER=${{ matrix.debian }}-slim + + # 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: ${{ env.DOCKER_CTX }} + push: true + tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }} + build-args: | + VT_BASE_VER=${TAG_NAME} + DEBIAN_VER=${{ matrix.debian }}-slim diff --git a/.github/workflows/docker_build_lite.yml b/.github/workflows/docker_build_lite.yml index 54c2bcb2419..7f355ddfd32 100644 --- a/.github/workflows/docker_build_lite.yml +++ b/.github/workflows/docker_build_lite.yml @@ -63,7 +63,7 @@ jobs: echo "DOCKER_TAG=vitess/lite:${TAG_NAME}-${{ matrix.branch }}" >> $GITHUB_ENV fi - - name: Build and push on main + - name: Build and push on tags if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v5 with: diff --git a/docker/k8s/Dockerfile b/docker/k8s/Dockerfile index 3ba46595a83..97ec478fb9f 100644 --- a/docker/k8s/Dockerfile +++ b/docker/k8s/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/base:${VT_BASE_VER} AS base +FROM frouioui/base:${VT_BASE_VER} AS base FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/mysqlctl/Dockerfile b/docker/k8s/mysqlctl/Dockerfile index 6c449552354..61523263d63 100644 --- a/docker/k8s/mysqlctl/Dockerfile +++ b/docker/k8s/mysqlctl/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/mysqlctld/Dockerfile b/docker/k8s/mysqlctld/Dockerfile index 6fdb30f012a..0aa70d48db0 100644 --- a/docker/k8s/mysqlctld/Dockerfile +++ b/docker/k8s/mysqlctld/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtadmin/Dockerfile b/docker/k8s/vtadmin/Dockerfile index f952681d3c9..1b774376171 100644 --- a/docker/k8s/vtadmin/Dockerfile +++ b/docker/k8s/vtadmin/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=bullseye-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM node:18-${DEBIAN_VER} as node diff --git a/docker/k8s/vtbackup/Dockerfile b/docker/k8s/vtbackup/Dockerfile index 4a8b3be9d52..665b53b390c 100644 --- a/docker/k8s/vtbackup/Dockerfile +++ b/docker/k8s/vtbackup/Dockerfile @@ -16,7 +16,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtctl/Dockerfile b/docker/k8s/vtctl/Dockerfile index cce3b6dc63c..cb3a0a5aa90 100644 --- a/docker/k8s/vtctl/Dockerfile +++ b/docker/k8s/vtctl/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtctlclient/Dockerfile b/docker/k8s/vtctlclient/Dockerfile index 17eab700eb4..b79b704b1e4 100644 --- a/docker/k8s/vtctlclient/Dockerfile +++ b/docker/k8s/vtctlclient/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtctld/Dockerfile b/docker/k8s/vtctld/Dockerfile index 5daaf929486..6884d0dca41 100644 --- a/docker/k8s/vtctld/Dockerfile +++ b/docker/k8s/vtctld/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtgate/Dockerfile b/docker/k8s/vtgate/Dockerfile index 3829227e2fa..fc7abbef45f 100644 --- a/docker/k8s/vtgate/Dockerfile +++ b/docker/k8s/vtgate/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vtorc/Dockerfile b/docker/k8s/vtorc/Dockerfile index b62b30ee676..7988fe088c0 100644 --- a/docker/k8s/vtorc/Dockerfile +++ b/docker/k8s/vtorc/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER} diff --git a/docker/k8s/vttablet/Dockerfile b/docker/k8s/vttablet/Dockerfile index dd504d7860d..f0b936518bb 100644 --- a/docker/k8s/vttablet/Dockerfile +++ b/docker/k8s/vttablet/Dockerfile @@ -15,7 +15,7 @@ ARG VT_BASE_VER=latest ARG DEBIAN_VER=stable-slim -FROM vitess/k8s:${VT_BASE_VER} AS k8s +FROM frouioui/k8s:${VT_BASE_VER} AS k8s FROM debian:${DEBIAN_VER}