Skip to content

Commit

Permalink
Build vitess component docker images
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Oct 17, 2023
1 parent 857286d commit 02a2d1a
Showing 1 changed file with 79 additions and 2 deletions.
81 changes: 79 additions & 2 deletions .github/workflows/docker_build_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -68,4 +68,81 @@ jobs:
context: .
file: ${{ env.DOCKERFILE }}
push: true
tags: ${{ env.DOCKER_TAG }}
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 }}

0 comments on commit 02a2d1a

Please sign in to comment.