Skip to content

Commit

Permalink
wip - attempt to use list type for build args
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Oct 18, 2023
1 parent 673ee53 commit ef2f02e
Showing 1 changed file with 85 additions and 69 deletions.
154 changes: 85 additions & 69 deletions .github/workflows/docker_build_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,69 +13,69 @@ concurrency:
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_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
# 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'
Expand Down Expand Up @@ -106,7 +106,9 @@ jobs:
context: ${{ env.DOCKER_CTX }}
push: true
tags: frouioui/k8s:latest
build-args: VT_BASE_VER=latest,DEBIAN_VER=${{ matrix.debian }}-slim
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'
Expand All @@ -115,7 +117,9 @@ jobs:
context: ${{ env.DOCKER_CTX }}
push: true
tags: frouioui/k8s:latest-${{ matrix.debian }}
build-args: VT_BASE_VER=latest,DEBIAN_VER=${{ matrix.debian }}-slim
build-args:
- VT_BASE_VER=latest
- DEBIAN_VER=${{ matrix.debian }}-slim

######
# All code below only applies to new tags
Expand Down Expand Up @@ -145,7 +149,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-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 @@ -156,7 +162,9 @@ jobs:
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-args:
- VT_BASE_VER=${TAG_NAME}
- DEBIAN_VER=${{ matrix.debian }}-slim


build_and_push_components:
Expand Down Expand Up @@ -192,7 +200,9 @@ jobs:
context: ${{ env.DOCKER_CTX }}
push: true
tags: frouioui/${{ matrix.component }}:latest
build-args: VT_BASE_VER=latest,DEBIAN_VER=${{ matrix.debian }}-slim
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'
Expand All @@ -201,7 +211,9 @@ jobs:
context: ${{ env.DOCKER_CTX }}
push: true
tags: frouioui/${{ matrix.component }}:latest-${{ matrix.debian }}
build-args: VT_BASE_VER=latest,DEBIAN_VER=${{ matrix.debian }}-slim
build-args:
- VT_BASE_VER=latest
- DEBIAN_VER=${{ matrix.debian }}-slim

######
# All code below only applies to new tags
Expand Down Expand Up @@ -231,7 +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-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 @@ -242,4 +256,6 @@ jobs:
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-args:
- VT_BASE_VER=${TAG_NAME}
- DEBIAN_VER=${{ matrix.debian }}-slim

0 comments on commit ef2f02e

Please sign in to comment.