Merge "containerfile: automatically search for distro docker files"

This commit is contained in:
Zuul 2021-05-12 08:19:00 +00:00 committed by Gerrit Code Review
commit 6919ebf4a7
2 changed files with 27 additions and 3 deletions

View File

@ -5,5 +5,10 @@ containerfile
Base element for creating images from container files (aka Base element for creating images from container files (aka
Dockerfiles). Dockerfiles).
To use this element, create a container file (Dockerfile), and supply Usually this element will be called via a more specific distro element
the path to that file in the environment variable `DIB_CONTAINER_FILE`. which provides an environment for building a full image. This element
will search active elements for a container file located in
`containerfiles/${DIB_RELEASE}`.
Alternatively, to use this element directly supply the path to a
container file in the environment variable `DIB_CONTAINER_FILE`.

View File

@ -25,7 +25,26 @@ if [ -f ${TARGET_ROOT}/.extra_settings ] ; then
. ${TARGET_ROOT}/.extra_settings . ${TARGET_ROOT}/.extra_settings
fi fi
[ -n "$DIB_CONTAINER_FILE" ] if [ -z "${DIB_CONTAINER_FILE:-}" ]; then
_xtrace=$(set +o | grep xtrace)
set +o xtrace
eval declare -A image_elements=($(get_image_element_array))
for i in "${!image_elements[@]}"; do
element=$i
element_dir=${image_elements[$i]}
containerfile="${element_dir}/containerfiles/${DIB_RELEASE}"
if [ -f "${containerfile}" ]; then
echo "Found container file ${containerfile}"
DIB_CONTAINER_FILE="${containerfile}"
break
fi
done
$_xtrace
fi
# Use the image cache directory as the default context, so anything # Use the image cache directory as the default context, so anything
# there is automatically available for COPY commands. # there is automatically available for COPY commands.