2019-01-26 06:29:13 +00:00
|
|
|
#!/usr/bin/env sh
|
2020-11-21 20:36:45 +00:00
|
|
|
export BUILDX_NO_DEFAULT_LOAD=true
|
2018-09-13 21:21:11 +00:00
|
|
|
|
2020-11-22 00:34:31 +00:00
|
|
|
: ${PREFER_BUILDCTL=}
|
|
|
|
: ${PREFER_LEGACY=}
|
2020-11-21 20:36:45 +00:00
|
|
|
: ${CI=}
|
|
|
|
: ${GITHUB_ACTIONS=}
|
2020-11-29 05:45:33 +00:00
|
|
|
: ${CACHEDIR_FROM=}
|
|
|
|
: ${CACHEDIR_TO=}
|
2018-09-13 21:21:11 +00:00
|
|
|
|
2020-11-26 04:36:30 +00:00
|
|
|
if [ "$PREFER_BUILDCTL" = "1" ]; then
|
|
|
|
echo >&2 "WARNING: PREFER_BUILDCTL is no longer supported. Ignoring."
|
2020-11-21 20:36:45 +00:00
|
|
|
fi
|
2018-09-13 21:21:11 +00:00
|
|
|
|
2020-11-26 04:36:30 +00:00
|
|
|
if [ "$PREFER_LEGACY" = "1" ]; then
|
|
|
|
echo >&2 "WARNING: PREFER_LEGACY is no longer supported. Ignoring."
|
2020-11-22 00:34:31 +00:00
|
|
|
fi
|
2020-11-26 04:36:30 +00:00
|
|
|
|
|
|
|
progressFlag=""
|
|
|
|
if [ "$CI" = "true" ]; then
|
|
|
|
progressFlag="--progress=plain"
|
2020-11-22 00:34:31 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-21 20:36:45 +00:00
|
|
|
buildxCmd() {
|
|
|
|
if docker buildx version >/dev/null 2>&1; then
|
|
|
|
set -x
|
|
|
|
docker buildx "$@" $progressFlag
|
|
|
|
elif buildx version >/dev/null 2>&1; then
|
|
|
|
set -x
|
|
|
|
buildx "$@" $progressFlag
|
|
|
|
else
|
2020-11-26 05:27:55 +00:00
|
|
|
topdir="$(realpath $(dirname "$0")/..)"
|
|
|
|
if [ ! -x "${topdir}/bin/buildx" ]; then
|
|
|
|
set -x
|
|
|
|
"${topdir}/hack/install-buildx"
|
|
|
|
fi
|
|
|
|
set -x
|
|
|
|
bootstrapName="moby-buildkit"
|
|
|
|
"${topdir}/hack/bootstrap-buildx" "${bootstrapName}"
|
|
|
|
BUILDX_BUILDER="${bootstrapName}" "${topdir}/bin/buildx" "$@" $progressFlag
|
2018-09-13 21:21:11 +00:00
|
|
|
fi
|
2020-11-21 20:36:45 +00:00
|
|
|
}
|
2019-08-08 00:50:00 +00:00
|
|
|
|
2020-11-29 05:45:33 +00:00
|
|
|
cacheType=""
|
|
|
|
cacheRefFrom=""
|
|
|
|
cacheRefTo=""
|
2019-08-08 00:50:00 +00:00
|
|
|
currentref=""
|
2020-11-21 20:36:45 +00:00
|
|
|
if [ "$GITHUB_ACTIONS" = "true" ]; then
|
2020-11-22 03:03:55 +00:00
|
|
|
currentref="git://github.com/$GITHUB_REPOSITORY#$GITHUB_REF"
|
2020-11-29 05:45:33 +00:00
|
|
|
cacheType="local"
|
|
|
|
cacheRefFrom="$CACHEDIR_FROM"
|
|
|
|
cacheRefTo="$CACHEDIR_TO"
|
2019-08-08 00:50:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
currentcontext="."
|
|
|
|
if [ -n "$currentref" ]; then
|
|
|
|
currentcontext="--build-arg BUILDKIT_CONTEXT_KEEP_GIT_DIR=1 $currentref"
|
2020-07-25 03:36:55 +00:00
|
|
|
fi
|