maint(developer): use docker buildx to build docker images

This change verifies that `docker buildx` is available and then uses that
for building the images. For that we apparently need the magic line at
the top of the `Dockerfile`s and set the environment variable
`DOCKER_BUILDKIT`. This solves a problem building docker images on
Linux with an older Docker version where the heredocs didn't work.
This commit is contained in:
Eberhard Beilharz 2025-06-06 18:10:42 +02:00
parent 739bdf788f
commit 33fe775aa7
No known key found for this signature in database
GPG key ID: E9140597606020D3
8 changed files with 20 additions and 0 deletions

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
ARG BASE_VERSION=default

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
ARG DISTRO=ubuntu

View file

@ -46,6 +46,7 @@ build_action() {
# shellcheck disable=SC2164
cd "${platform}"
export DOCKER_BUILDKIT=1
# shellcheck disable=SC2248,SC2086
docker build ${OPTION_NO_CACHE:-} -t "keymanapp/keyman-${platform}-ci:${build_version}" "${build_args[@]}" .
# If the user didn't specify particular versions we will additionaly create an image
@ -67,6 +68,7 @@ test_action() {
":${platform}" -- ./build.sh configure,build,test:"${platform}"
}
check_buildx_available
check_for_default_values
convert_parameters_to_args

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
#
# ARGS used in this file:

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
#
# ARGS used in this file:

View file

@ -59,3 +59,15 @@ check_for_default_values() {
is_default_values() {
${is_default_values}
}
# Check that `docker buildx` is available
check_buildx_available() {
if ! docker --help | grep -q buildx; then
if [[ "${OSTYPE:-}" == "linux-gnu" ]]; then
builder_echo error "Docker buildx is not available. Please install Docker buildx to use this script. e.g. 'sudo apt install docker-buildx'"
else
builder_echo error "Docker buildx is not available. Please install Docker buildx to use this script."
fi
exit 1
fi
}

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
ARG BASE_VERSION=default

View file

@ -1,3 +1,4 @@
# syntax=docker/dockerfile:1.4
# Keyman is copyright (C) SIL Global. MIT License.
#
# ARGS used in this file: