#!/usr/bin/env bash # Build and push the three custom images to the registry. Runs on the CI runner. # Requires a buildx builder that supports registry cache export (docker-container driver); # the workflow sets one up. Uses registry-backed layer cache so unchanged images (notably # the concordancer, whose build downloads a large lexicon from clarin.si) are near-instant. # # Required environment: # REGISTRY image name prefix, e.g. gitea.example.tld/luka # TAG tag to build, e.g. sha-abc1234 set -euo pipefail : "${REGISTRY:?}" "${TAG:?}" # service | context | dockerfile builds=( "termportal-express|express|express/Dockerfile.prod" "termportal-opensearch|opensearch|opensearch/Dockerfile" "termportal-concordancer|concordancer|concordancer/Dockerfile.prod" ) for spec in "${builds[@]}"; do IFS='|' read -r name context dockerfile <<<"$spec" ref="$REGISTRY/$name" echo "+ build $ref:$TAG (context=$context, dockerfile=$dockerfile)" >&2 docker buildx build \ --file "$dockerfile" \ --tag "$ref:$TAG" \ --cache-from "type=registry,ref=$ref:buildcache" \ --cache-to "type=registry,ref=$ref:buildcache,mode=max" \ --push \ "$context" done