1
0
mirror of https://github.com/docker-library/haproxy.git synced 2025-04-17 23:57:35 +03:00
haproxy/apply-templates.sh
2024-05-29 19:31:58 +02:00

54 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -Eeuo pipefail
[ -f versions.json ] # run "versions.sh" first
jqt='.jq-template.awk'
if [ -n "${BASHBREW_SCRIPTS:-}" ]; then
jqt="$BASHBREW_SCRIPTS/jq-template.awk"
elif [ "$BASH_SOURCE" -nt "$jqt" ]; then
# https://github.com/docker-library/bashbrew/blob/master/scripts/jq-template.awk
wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/9f6a35772ac863a0241f147c820354e4008edf38/scripts/jq-template.awk'
fi
if [ "$#" -eq 0 ]; then
versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)"
eval "set -- $versions"
fi
generated_warning() {
cat <<-EOH
#
# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh"
#
# PLEASE DO NOT EDIT IT DIRECTLY.
#
EOH
}
for version; do
rm -rf "$version/"
for variant in '' alpine; do
# 2.2 can't be built on Alpine greater than 3.16
# OpenSSL 3 incompatibilities (https://github.com/haproxy/haproxy/issues/1276)
# but Alpine 3.16 is end of life
if [ "$version" = '2.2' ] && [ "$variant" = 'alpine' ]; then
continue
fi
export version variant
dir="$version${variant:+/$variant}"
echo "processing $dir ..."
mkdir -p "$dir"
{
generated_warning
gawk -f "$jqt" Dockerfile.template
} > "$dir/Dockerfile"
cp -a docker-entrypoint.sh "$dir/"
done
done