Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: Enable building images with root context #37

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set -o nounset

MAKER_IMAGE="${MAKER_IMAGE:-docker.io/cilium/image-maker:bc81755ec8f6c5afcb10a416cef73f99a35fee2c}"

with_root_context="${ROOT_CONTEXT:-false}"

if [ "$#" -lt 6 ] ; then
echo "$0 supports minimum 6 argument"
exit 1
Expand All @@ -29,7 +31,11 @@ shift 5

registries=("${@}")

image_tag="$("${root_dir}/scripts/make-image-tag.sh" "${image_dir}")"
if [ "${with_root_context}" = "false" ] ; then
image_tag="$("${root_dir}/images/scripts/make-image-tag.sh" "${image_dir}")"
else
image_tag="$("${root_dir}/images/scripts/make-image-tag.sh")"
fi

tag_args=()
for registry in "${registries[@]}" ; do
Expand Down Expand Up @@ -84,12 +90,22 @@ if [ "${do_build}" = "false" ] ; then
fi

run_buildx() {
docker buildx build \
"${tag_args[@]}" \
--platform "${platform}" \
--output "${output}" \
--builder "${builder}" \
"${image_dir}"
if [ "${with_root_context}" = "false" ] ; then
docker buildx build \
"${tag_args[@]}" \
--platform "${platform}" \
--output "${output}" \
--builder "${builder}" \
"${image_dir}"
else
docker buildx build \
"${tag_args[@]}" \
--platform "${platform}" \
--output "${output}" \
--builder "${builder}" \
--file "${image_dir}/Dockerfile" \
"${root_dir}"
fi
}

if [ "${do_build}" = "true" ] ; then
Expand Down