osbuilder: Allow image registry to be customizable

Give the user chance to specify their own registry in event the default
provided are not accessible, desirable.

Fixes: #1393

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
This commit is contained in:
Eric Ernst 2021-02-10 12:32:55 -08:00
parent cb6d2f3c40
commit 49bdbac606
2 changed files with 28 additions and 11 deletions

View File

@ -84,14 +84,15 @@ Options:
-r Free space of the root partition in MB ENV: ROOT_FREE_SPACE -r Free space of the root partition in MB ENV: ROOT_FREE_SPACE
Extra environment variables: Extra environment variables:
AGENT_BIN: Use it to change the expected agent binary name AGENT_BIN: Use it to change the expected agent binary name
AGENT_INIT: Use kata agent as init process AGENT_INIT: Use kata agent as init process
FS_TYPE: Filesystem type to use. Only xfs and ext4 are supported. IMAGE_REGISTRY: Hostname for the image registry used to pull down the rootfs build image.
NSDAX_BIN: Use to specify path to pre-compiled 'nsdax' tool. FS_TYPE: Filesystem type to use. Only xfs and ext4 are supported.
USE_DOCKER: If set will build image in a Docker Container (requries docker) NSDAX_BIN: Use to specify path to pre-compiled 'nsdax' tool.
DEFAULT: not set USE_DOCKER: If set will build image in a Docker Container (requries docker)
USE_PODMAN: If set and USE_DOCKER not set, will build image in a Podman Container (requries podman) DEFAULT: not set
DEFAULT: not set USE_PODMAN: If set and USE_DOCKER not set, will build image in a Podman Container (requries podman)
DEFAULT: not set
Following diagram shows how the resulting image will look like Following diagram shows how the resulting image will look like
@ -137,7 +138,13 @@ build_with_container() {
image_dir=$(readlink -f "$(dirname "${image}")") image_dir=$(readlink -f "$(dirname "${image}")")
image_name=$(basename "${image}") image_name=$(basename "${image}")
REGISTRY_ARG=""
if [ -n "${IMAGE_REGISTRY}" ]; then
REGISTRY_ARG="--build-arg IMAGE_REGISTRY=${IMAGE_REGISTRY}"
fi
"${container_engine}" build \ "${container_engine}" build \
${REGISTRY_ARG} \
--build-arg http_proxy="${http_proxy}" \ --build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \ --build-arg https_proxy="${https_proxy}" \
-t "${container_image_name}" "${script_dir}" -t "${container_image_name}" "${script_dir}"

View File

@ -100,13 +100,13 @@ AGENT_INIT When set to "yes", use ${AGENT_BIN} as init process in place
of systemd. of systemd.
Default value: no Default value: no
AGENT_VERSION Version of the agent to include in the rootfs.
Default value: ${AGENT_VERSION:-<not set>}
AGENT_SOURCE_BIN Path to the directory of agent binary. AGENT_SOURCE_BIN Path to the directory of agent binary.
If set, use the binary as agent but not build agent package. If set, use the binary as agent but not build agent package.
Default value: <not set> Default value: <not set>
AGENT_VERSION Version of the agent to include in the rootfs.
Default value: ${AGENT_VERSION:-<not set>}
DISTRO_REPO Use host repositories to install guest packages. DISTRO_REPO Use host repositories to install guest packages.
Default value: <not set> Default value: <not set>
@ -123,6 +123,10 @@ GRACEFUL_EXIT If set, and if the DISTRO configuration specifies a
specific distributions. specific distributions.
Default value: <not set> Default value: <not set>
IMAGE_REGISTRY Hostname for the image registry used to pull down the rootfs
build image.
Default value: docker.io
KERNEL_MODULES_DIR Path to a directory containing kernel modules to include in KERNEL_MODULES_DIR Path to a directory containing kernel modules to include in
the rootfs. the rootfs.
Default value: <empty> Default value: <empty>
@ -371,9 +375,15 @@ build_rootfs_distro()
image_name="${distro}-rootfs-osbuilder" image_name="${distro}-rootfs-osbuilder"
REGISTRY_ARG=""
if [ -n "${IMAGE_REGISTRY}" ]; then
REGISTRY_ARG="--build-arg IMAGE_REGISTRY=${IMAGE_REGISTRY}"
fi
# setup to install go or rust here # setup to install go or rust here
generate_dockerfile "${distro_config_dir}" generate_dockerfile "${distro_config_dir}"
"$container_engine" build \ "$container_engine" build \
${REGISTRY_ARG} \
--build-arg http_proxy="${http_proxy}" \ --build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \ --build-arg https_proxy="${https_proxy}" \
-t "${image_name}" "${distro_config_dir}" -t "${image_name}" "${distro_config_dir}"