intel-device-plugins-for-ku.../build/docker/build-image.sh
Mikko Ylinen 900d0ebf9c images: have base image specific toybox config
Our *.Dockefile's allow builders to specify FINAL_BASE base image
to which static binaries are copied for the final image.

Initcontainers install toybox with a minimum set of "coreutils"
needed but with some final base images the minimum set can be
even smaller since they may already have /bin/sh, ls etc. installed.

Make initcontainers to have base image specific toybox-config.
For now, "static" for distroles/static and "ubi8-micro" for
UBI base image configs are created.

At the same time, move the toybox build to "usrmerge" based
setup where everything is installed to /usr/bin and /bin is
a symlink to /usr/bin. buildkit does not seem to like it so
disable buildkit usage for now.

Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
2023-09-08 09:38:18 +03:00

41 lines
1.1 KiB
Bash
Executable File

#!/bin/sh -e
IMG=$1
DOCKERFILE="$(dirname $0)/$(basename ${IMG}).Dockerfile"
if [ -z "$IMG" ]; then
(>&2 echo "Usage: $0 <Dockerfile>")
exit 1
fi
if [ ! -e "${DOCKERFILE}" ]; then
(>&2 echo "File ${DOCKERFILE} doesn't exist")
exit 1
fi
shift
if [ "$1" = 'docker' -o "$1" = 'buildah' -o "$1" = 'podman' ]; then
BUILDER=$1
shift
fi
TAG=${TAG:-devel}
BUILD_ARGS=$@
if [ -d $(dirname $0)/../../vendor ] ; then
echo "Building images with vendored code"
BUILD_ARGS="${BUILD_ARGS} --build-arg DIR=/go/src/github.com/intel/intel-device-plugins-for-kubernetes --build-arg GO111MODULE=off"
fi
BUILD_ARGS="${BUILD_ARGS} --build-arg FINAL_BASE=gcr.io/distroless/static"
if [ -z "${BUILDER}" -o "${BUILDER}" = 'docker' -o "${BUILDER}" = 'podman' ] ; then
DOCKER_BUILDKIT=0 ${BUILDER} build --pull -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
elif [ "${BUILDER}" = 'buildah' ] ; then
BUILDAH_RUNTIME=runc buildah bud --pull-always -t ${IMG}:${TAG} ${BUILD_ARGS} -f ${DOCKERFILE} .
else
(>&2 echo "Unknown builder ${BUILDER}")
exit 1
fi