Docker Build #49
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Build | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to build' | |
required: true | |
tag_as_latest: | |
description: 'Tag this version as latest' | |
type: boolean | |
default: true | |
required: false | |
jobs: | |
docker: | |
strategy: | |
matrix: | |
include: | |
- platform: linux/amd64 | |
runner: ubicloud-standard-16 # AMD64 runner | |
- platform: linux/arm64 | |
runner: ubicloud-standard-16-arm # ARM64 runner | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
# This enables the docker driver with persistent worker | |
driver-opts: | | |
image=moby/buildkit:latest | |
network=host | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Extract platform info | |
id: platform | |
run: | | |
ARCH=${MATRIX_PLATFORM#*/} | |
echo "arch=$ARCH" >> $GITHUB_OUTPUT | |
env: | |
MATRIX_PLATFORM: ${{ matrix.platform }} | |
# Add cache metadata extraction | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: sequin/sequin | |
tags: | | |
type=semver,pattern={{version}},value=${{ inputs.version }} | |
${{ inputs.tag_as_latest == 'true' && 'type=raw,value=latest' || '' }} | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: ${{ matrix.platform }} | |
push: true | |
build-args: | | |
SELF_HOSTED=1 | |
RELEASE_VERSION=${{ inputs.version }} | |
tags: | | |
sequin/sequin:${{ inputs.version }}-${{ steps.platform.outputs.arch }} | |
cache-from: | | |
type=registry,ref=sequin/sequin:buildcache-${{ steps.platform.outputs.arch }} | |
cache-to: | | |
type=registry,ref=sequin/sequin:buildcache-${{ steps.platform.outputs.arch }},mode=max | |
provenance: false | |
sbom: false | |
create-manifest: | |
needs: docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Create and push manifest | |
run: | | |
docker buildx imagetools create -t sequin/sequin:${{ inputs.version }} \ | |
sequin/sequin:${{ inputs.version }}-amd64 \ | |
sequin/sequin:${{ inputs.version }}-arm64 | |
if [[ "${{ inputs.tag_as_latest }}" == "true" ]]; then | |
docker buildx imagetools create -t sequin/sequin:latest \ | |
sequin/sequin:${{ inputs.version }}-amd64 \ | |
sequin/sequin:${{ inputs.version }}-arm64 | |
fi |