Skip to content

Commit f672a96

Browse files
committed
Propagate BUILD_APT_MIRROR and consume in buil-deb
Passses down BUILD_APT_MIRROR to the docker env. Ensures BUILD_APT_MIRROR is used when building debs, but only when the consuming `Dockerfile` actually uses it, otherwise it will cause the build to fail (e.g. on Ubuntu builds we aren't using APT_MIRROR). Signed-off-by: Brian Goff <[email protected]>
1 parent a123ef1 commit f672a96

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $$
1111
# to allow things like `make KEEPBUNDLE=1 binary` easily
1212
# `project/PACKAGERS.md` have some limited documentation of some of these
1313
DOCKER_ENVS := \
14+
-e BUILD_APT_MIRROR \
1415
-e BUILDFLAGS \
1516
-e KEEPBUNDLE \
1617
-e DOCKER_BUILD_ARGS \
@@ -60,6 +61,7 @@ DOCKER_PORT_FORWARD := $(if $(DOCKER_PORT),-p "$(DOCKER_PORT)",)
6061

6162
DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD)
6263
BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR))
64+
export BUILD_APT_MIRROR
6365

6466
# if this session isn't interactive, then we don't want to allocate a
6567
# TTY, which would fail, but if it is interactive, we do want to attach

hack/make/build-deb

+8-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ set -e
5252

5353
image="dockercore/builder-deb:$version"
5454
if ! docker inspect "$image" &> /dev/null; then
55-
( set -x && docker build ${DOCKER_BUILD_ARGS} -t "$image" "$dir" )
55+
(
56+
# Add the APT_MIRROR args only if the consuming Dockerfile uses it
57+
# Otherwise this will cause the build to fail
58+
if [ "$(grep 'ARG APT_MIRROR=' $dir/Dockerfile)" ] && [ "$BUILD_APT_MIRROR" ]; then
59+
DOCKER_BUILD_ARGS="$DOCKER_BUILD_ARGS $BUILD_APT_MIRROR"
60+
fi
61+
set -x && docker build ${DOCKER_BUILD_ARGS} -t "$image" "$dir"
62+
)
5663
fi
5764

5865
mkdir -p "$DEST/$version"

0 commit comments

Comments
 (0)