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 <cpuguy83@gmail.com>
... | ... |
@@ -11,6 +11,7 @@ DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $$ |
11 | 11 |
# to allow things like `make KEEPBUNDLE=1 binary` easily |
12 | 12 |
# `project/PACKAGERS.md` have some limited documentation of some of these |
13 | 13 |
DOCKER_ENVS := \ |
14 |
+ -e BUILD_APT_MIRROR \ |
|
14 | 15 |
-e BUILDFLAGS \ |
15 | 16 |
-e KEEPBUNDLE \ |
16 | 17 |
-e DOCKER_BUILD_ARGS \ |
... | ... |
@@ -60,6 +61,7 @@ DOCKER_PORT_FORWARD := $(if $(DOCKER_PORT),-p "$(DOCKER_PORT)",) |
60 | 60 |
|
61 | 61 |
DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) $(DOCKER_PORT_FORWARD) |
62 | 62 |
BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR)) |
63 |
+export BUILD_APT_MIRROR |
|
63 | 64 |
|
64 | 65 |
# if this session isn't interactive, then we don't want to allocate a |
65 | 66 |
# TTY, which would fail, but if it is interactive, we do want to attach |
... | ... |
@@ -52,7 +52,14 @@ set -e |
52 | 52 |
|
53 | 53 |
image="dockercore/builder-deb:$version" |
54 | 54 |
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 |
+ ) |
|
56 | 63 |
fi |
57 | 64 |
|
58 | 65 |
mkdir -p "$DEST/$version" |