containerfile: Add support for setting network driver

Change-Id: Ia885237406bf4c7b9d49b349f374558ae746401f
This commit is contained in:
Michal Nasiadka 2022-03-15 13:17:42 +00:00
parent bce7af6a29
commit 7d782ae1c9
2 changed files with 11 additions and 2 deletions

View File

@ -19,3 +19,6 @@ images (default is ``podman``).
Set ``DIB_CONTAINERFILE_RUNTIME_ROOT`` to ``1`` to run the runtime
(Docker or ``podman``, per above) as ``root``.
Set ``DIB_CONTAINERFILE_NETWORK_DRIVER`` to a network driver of your choice
(e.g. host) to use it instead of the default bridge during build.

View File

@ -28,6 +28,12 @@ if [[ "${DIB_CONTAINERFILE_PODMAN_ROOT:-0}" != '0' ]]; then
DIB_CONTAINERFILE_RUNTIME_ROOT=1
fi
if [[ -z "${DIB_CONTAINERFILE_NETWORK_DRIVER:-}" ]]; then
DIB_CONTAINERFILE_RUNTIME_NETWORK=""
else
DIB_CONTAINERFILE_RUNTIME_NETWORK="--network ${DIB_CONTAINERFILE_NETWORK_DRIVER:-}"
fi
if [ -f ${TARGET_ROOT}/.extra_settings ] ; then
. ${TARGET_ROOT}/.extra_settings
fi
@ -77,8 +83,8 @@ function podman_cleanup() {
trap "podman_cleanup" EXIT
${_sudo} ${DIB_CONTAINERFILE_RUNTIME} build -t ${_podman_build_image} -f $DIB_CONTAINERFILE_DOCKERFILE $DIB_CONTAINER_CONTEXT
${_sudo} ${DIB_CONTAINERFILE_RUNTIME} run --name ${_podman_export_container} -d ${_podman_build_image} /bin/sh
${_sudo} ${DIB_CONTAINERFILE_RUNTIME} build ${DIB_CONTAINERFILE_RUNTIME_NETWORK} -t ${_podman_build_image} -f $DIB_CONTAINERFILE_DOCKERFILE $DIB_CONTAINER_CONTEXT
${_sudo} ${DIB_CONTAINERFILE_RUNTIME} run ${DIB_CONTAINERFILE_RUNTIME_NETWORK} --name ${_podman_export_container} -d ${_podman_build_image} /bin/sh
# NOTE(ianw) 2021-11-10 the tar must always be sudo to write out the chroot files
# as other uids
${_sudo} ${DIB_CONTAINERFILE_RUNTIME} export ${_podman_export_container} | sudo tar -C $TARGET_ROOT --numeric-owner -xf -