Revert "Merge branch 'multiarch-images' into 'master'"

This reverts merge request !577
This commit is contained in:
Balasankar 'Balu' C 2022-09-19 10:15:53 +00:00
parent 7fc85c87db
commit 514f304d5f
16 changed files with 66 additions and 53 deletions

View file

@ -7,7 +7,7 @@ source "$SCRIPT_DIR/custom-docker.sh"
function get_base_image_reference() {
if [[ $1 =~ ^debian ]]; then
echo "$1"
echo "$CUSTOM_DOCKER_ARCH/$1"
elif [[ $1 =~ ^ubi:8 ]]; then
echo "registry.access.redhat.com/ubi8/$1"
fi
@ -20,23 +20,23 @@ function print_golang_args() {
1.16)
INSTALL_GOLANG_VERSION=1.16.12
GOLANG_DOWNLOAD_SHA256[amd64]=7d657e86493ac1d5892f340a7d88b862b12edb5ac6e73c099e8e0668a6c916b7
GOLANG_DOWNLOAD_SHA256[arm64]=7dbf50ab2e665ecd6c86a3f1ce8c04f7167f9895b91921e25cf1bdc1cb9b5fd7
GOLANG_DOWNLOAD_SHA256[arm64v8]=7dbf50ab2e665ecd6c86a3f1ce8c04f7167f9895b91921e25cf1bdc1cb9b5fd7
;;
1.17)
INSTALL_GOLANG_VERSION=1.17.13
GOLANG_DOWNLOAD_SHA256[amd64]=4cdd2bc664724dc7db94ad51b503512c5ae7220951cac568120f64f8e94399fc
GOLANG_DOWNLOAD_SHA256[arm64]=914daad3f011cc2014dea799bb7490442677e4ad6de0b2ac3ded6cee7e3f493d
GOLANG_DOWNLOAD_SHA256[arm64v8]=914daad3f011cc2014dea799bb7490442677e4ad6de0b2ac3ded6cee7e3f493d
;;
1.18)
INSTALL_GOLANG_VERSION=1.18.5
GOLANG_DOWNLOAD_SHA256[amd64]=9e5de37f9c49942c601b191ac5fba404b868bfc21d446d6960acc12283d6e5f2
GOLANG_DOWNLOAD_SHA256[arm64]=006f6622718212363fa1ff004a6ab4d87bbbe772ec5631bab7cac10be346e4f1
GOLANG_DOWNLOAD_SHA256[arm64v8]=006f6622718212363fa1ff004a6ab4d87bbbe772ec5631bab7cac10be346e4f1
;;
*) echo "Unknown golang version $1"; exit 1;
esac
printf -- "--build-arg INSTALL_GOLANG_VERSION=%s " "$INSTALL_GOLANG_VERSION"
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "${GOLANG_DOWNLOAD_SHA256[$TARGETARCH]}"
printf -- "--build-arg GOLANG_DOWNLOAD_SHA256=%s " "${GOLANG_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
}
# If you add a new minor version here, be sure to check that the
@ -93,13 +93,13 @@ function print_lfs_args() {
2.9)
LFS_VERSION=2.9.1
LFS_DOWNLOAD_SHA256[amd64]=2a8e60cf51ec45aa0f4332aa0521d60ec75c76e485d13ebaeea915b9d70ea466
LFS_DOWNLOAD_SHA256[arm64]=ff2f8472a5ac0e808108bad0cc6be5ca1849eb970228b1aa3d627bcbc8228ad9
LFS_DOWNLOAD_SHA256[arm64v8]=ff2f8472a5ac0e808108bad0cc6be5ca1849eb970228b1aa3d627bcbc8228ad9
;;
*) echo "Unknown Git LFS version $1"; exit 1;
esac
printf -- "--build-arg LFS_VERSION=%s " "$LFS_VERSION"
printf -- "--build-arg LFS_DOWNLOAD_SHA256=%s " "${LFS_DOWNLOAD_SHA256[$TARGETARCH]}"
printf -- "--build-arg LFS_DOWNLOAD_SHA256=%s " "${LFS_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
}
function print_node_args() {
@ -138,13 +138,13 @@ function print_buildx_args() {
0.8)
BUILDX_VERSION=0.8.2
BUILDX_DOWNLOAD_SHA256[amd64]=c64de4f3c30f7a73ff9db637660c7aa0f00234368105b0a09fa8e24eebe910c3
BUILDX_DOWNLOAD_SHA256[arm64]=304d3d9822c75f98ad9cf57f0c234bcf326bbb96d791d551728cadd72a7a377f
BUILDX_DOWNLOAD_SHA256[arm64v8]=304d3d9822c75f98ad9cf57f0c234bcf326bbb96d791d551728cadd72a7a377f
;;
*) echo "Unknown buildx version $1"; exit 1;
esac
printf -- "--build-arg BUILDX_VERSION=%s " "$BUILDX_VERSION"
printf -- "--build-arg BUILDX_DOWNLOAD_SHA256=%s " "${BUILDX_DOWNLOAD_SHA256[$TARGETARCH]}"
printf -- "--build-arg BUILDX_DOWNLOAD_SHA256=%s " "${BUILDX_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
}
function print_graphicsmagick_args() {
@ -268,7 +268,7 @@ function print_kubectl_args() {
esac
printf -- "--build-arg KUBECTL_VERSION=%s " "$KUBECTL_VERSION"
printf -- "--build-arg KUBECTL_DOWNLOAD_SHA256=%s " "${KUBECTL_DOWNLOAD_SHA256[$TARGETARCH]}"
printf -- "--build-arg KUBECTL_DOWNLOAD_SHA256=%s " "${KUBECTL_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
}
function print_helm_args() {
@ -284,29 +284,57 @@ function print_helm_args() {
esac
printf -- "--build-arg HELM_VERSION=%s " "$HELM_VERSION"
printf -- "--build-arg HELM_DOWNLOAD_SHA256=%s " "${HELM_DOWNLOAD_SHA256[$TARGETARCH]}"
printf -- "--build-arg HELM_DOWNLOAD_SHA256=%s " "${HELM_DOWNLOAD_SHA256[$CUSTOM_DOCKER_ARCH]}"
}
function parse_arguments() {
printf -- "-f Dockerfile.custom "
# We make use of 2 variables related to the build environment.
# Mapping between sources of architectures
# - arch: a current image architecture (or uname -m if matching host, but can be different)
# - apk --print-arch: a alpine architecture for installed packages
# - dpkg --print-architecture: a debian architecture for installed packages
# - docker arch: a Docker Hub architecture for images
#
# arch | apk --print-arch | dpkg --print-architecture | docker arch
# x86_64 | x86_64 | amd64 | amd64
# armhf | armhf | armhf | arm32v7
# aarch64 | aarch64 | arm64 | arm64v8
# We make use of 4 variables related to the build environment.
# 1. `CUSTOM_DOCKER_IMAGE` - Defines the reference of image used as
# base for building images. Follows a
# valid docker image reference format
# - "debian:buster"
# - "arm64v8/debian:buster"
# - "registry.access.redhat.com/ubi8/ubi:8.6"
# 2. `BUILD_OS` - Used by installation scripts of various
# 2. `CUSTOM_DOCKER_ARCH` - Defines the architecture of the docker
# image. Follows docker architecture
# format - `amd64`/`arm32v7`/`arm64v8`.
# 3. `BUILD_OS` - Used by installation scripts of various
# components to detect the OS being worked
# on. Follows regular docker image:tag
# format - "debian:buster" or "ubi:8.6".
# 4. `BUILD_ARCH` - Used by installation scripts of various
# components to detect the architecture
# being worked on. Follows general
# architecture names - `amd64`/`arm64`.
#
# The first two variables are used to pick the docker image used as
# base for builds. The last two variables are used to detect OS and
# architecture while building components.
TARGETARCH=${ARCH:-amd64}
# defaults
case $(arch) in
x86_64) CUSTOM_DOCKER_ARCH=amd64; BUILD_ARCH=amd64 ;;
aarch64) CUSTOM_DOCKER_ARCH=arm64v8; BUILD_ARCH=arm64 ;;
*) echo "unknown architecture $(arch)"; exit 1;;
esac
for tool in "${PATH_TOOLS[@]}" "${TAG_TOOLS[@]}"; do
if [ -n "${!tool}" ]; then
version="${!tool}"
case "$tool" in
ARCH) CUSTOM_DOCKER_ARCH=$version ;;
OS) CUSTOM_BASE_IMAGE=$(get_base_image_reference $version) ;;
RUBY) print_ruby_args $version ;;
BUNDLER) print_bundler_args $version ;;
@ -330,12 +358,15 @@ function parse_arguments() {
fi
done
CUSTOM_BASE_IMAGE=${CUSTOM_BASE_IMAGE:-"debian:buster"}
if [ -z "$CUSTOM_BASE_IMAGE" ]; then
CUSTOM_BASE_IMAGE="$CUSTOM_DOCKER_ARCH/debian:buster"
fi
BUILD_OS=${OS:-"debian:buster"}
printf -- "--build-arg CUSTOM_BASE_IMAGE=%s " "$CUSTOM_BASE_IMAGE"
printf -- "--build-arg BUILD_OS=%s " "$BUILD_OS"
printf -- "--platform=linux/%s " "${TARGETARCH}"
printf -- "--build-arg BUILD_ARCH=%s " "$BUILD_ARCH"
}
function generate_command() {