@@ -7,6 +7,8 @@ SPACE := $(NULL) #
COMMA := ,
HOST_ARCH = $(if $(ARCH),$(ARCH),$(shell uname -m))
+USER = $(if $(NOUSER),,$(shell id -un))
+UID = $(if $(NOUSER),,$(shell id -u))
DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
ifeq ($(HOST_ARCH),x86_64)
@@ -90,23 +92,25 @@ docker-image-debian-native: DOCKER_REGISTRY=
# alpine has no adduser
docker-image-alpine: NOUSER=1
-debian-toolchain-run = \
- $(if $(NOCACHE), \
- $(call quiet-command, \
- $(DOCKER_SCRIPT) build -t qemu/$1 -f $< \
- $(if $V,,--quiet) --no-cache \
- --registry $(DOCKER_REGISTRY) --extra-files \
- $(DOCKER_FILES_DIR)/$1.d/build-toolchain.sh, \
- "BUILD", $1), \
- $(call quiet-command, \
- $(DOCKER_SCRIPT) fetch $(if $V,,--quiet) \
- qemu/$1 $(DOCKER_REGISTRY), \
- "FETCH", $1) \
- $(call quiet-command, \
- $(DOCKER_SCRIPT) update $(if $V,,--quiet) \
- qemu/$1 \
- $(if $(NOUSER),,--add-current-user) \
- "PREPARE", $1))
+debian-toolchain-run = \
+ $(call quiet-command, \
+ $(RUNC) pull \
+ $(if $V,,--quiet) \
+ $(DOCKER_REGISTRY)/qemu/$1, \
+ "FETCH", $1); \
+ $(call quiet-command, \
+ $(RUNC) build \
+ $(if $V,,--quiet) \
+ $(if $(NOCACHE),--no-cache) \
+ $(if $(NOUSER),, \
+ --build-arg USER=$(USER) \
+ --build-arg UID=$(UID)) \
+ -t qemu/$1 \
+ -f - \
+ $(DOCKER_FILES_DIR)/$1.d \
+ < $<, \
+ "BUILD", $1)
+
debian-toolchain = $(call debian-toolchain-run,$(patsubst docker-image-%,%,$1))
docker-image-debian-hexagon-cross: $(DOCKER_FILES_DIR)/debian-hexagon-cross.docker \
@@ -48,3 +48,8 @@ RUN apt update && \
apt build-dep -yy --arch-only qemu
COPY --from=0 /usr/local /usr/local
ENV PATH $PATH:/usr/local/bin/
+
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
@@ -35,3 +35,8 @@ RUN cd /root && ./build-toolchain.sh
# then copying the built toolchain from stage 0.
FROM docker.io/library/debian:bullseye-slim
COPY --from=0 /usr/local /usr/local
+
+# As a final step configure the user (if env is defined)
+ARG USER
+ARG UID
+RUN if [ "${USER}" ]; then id ${USER} 2>/dev/null || useradd -u ${UID} -U ${USER}; fi
We don't really need stuff from docker.py to do the build as we have everything we need with a direct call. We do need to tweak the dockerfiles so we can redo the UID/name mapping as the last step. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- tests/docker/Makefile.include | 38 ++++++++++--------- .../dockerfiles/debian-hexagon-cross.docker | 5 +++ .../dockerfiles/debian-toolchain.docker | 5 +++ 3 files changed, 31 insertions(+), 17 deletions(-)