Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build and push Docker vitess/base and component images to DockerHub from GitHub Actions #14271

Merged
merged 21 commits into from
Oct 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add one more job to build k8s between base and other components
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
  • Loading branch information
frouioui committed Oct 17, 2023
commit 89a78f505daa5a3b5a9ddf79ce77920aa4d28cd9
140 changes: 122 additions & 18 deletions .github/workflows/docker_build_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
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
Expand All @@ -70,9 +74,101 @@ jobs:
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_base
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'
Expand All @@ -81,7 +177,7 @@ jobs:
fail-fast: true
matrix:
debian: [ bullseye, bookworm ]
component: [ k8s, vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, logrotate, logtail ]
component: [ vtadmin, vtorc, vtgate, vttablet, mysqlctld, mysqlctl, vtctl, vtctlclient, vtctld, logrotate, logtail ]

steps:
- name: Check out code
Expand All @@ -95,29 +191,29 @@ jobs:

- name: Set Docker context path
run: |
if [[ "${{ matrix.component }}" == "k8s" ]]; then
echo "DOCKER_CTX=./docker/k8s" >> $GITHUB_ENV
else
echo "DOCKER_CTX=./docker/k8s/${{ matrix.component }}" >> $GITHUB_ENV
fi
echo "DOCKER_CTX=./docker/k8s/${{ matrix.component }}" >> $GITHUB_ENV

# Build and Push component image to tag "latest" if branch=main and debian=bookworm
- name: Build and push on main Bookworm (default)
- 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

# 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'
- 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-bullseye
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
Expand All @@ -128,14 +224,16 @@ jobs:
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
#
# 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=frouioui/${{ matrix.component }}:${TAG_NAME}-${{ matrix.debian }}" >> $GITHUB_ENV
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
Expand All @@ -145,6 +243,9 @@ jobs:
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
Expand All @@ -154,4 +255,7 @@ jobs:
with:
context: ${{ env.DOCKER_CTX }}
push: true
tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }}
tags: ${{ env.DOCKER_TAG_DEFAULT_DEBIAN }}
build-args:
VT_BASE_VER: ${TAG_NAME}
DEBIAN_VER: ${{ matrix.debian }}-slim