Skip to content

Commit

Permalink
Merge pull request #1647 from Timmmm/user/timh/fix_docker_user_2
Browse files Browse the repository at this point in the history
Run root Docker as the current user
  • Loading branch information
wmat authored Sep 25, 2024
2 parents e867a4e + dfdf775 commit 9648e5e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# SPDX-License-Identifier: CC-BY-SA-4.0
#
# Description:
#
# This Makefile is designed to automate the process of building and packaging
# the documentation for RISC-V ISA Manuals. It supports multiple build targets
#
# This Makefile is designed to automate the process of building and packaging
# the documentation for RISC-V ISA Manuals. It supports multiple build targets
# for generating documentation in various formats (PDF, HTML, EPUB).
#
# Building with a preinstalled docker container is recommended.
Expand All @@ -27,13 +27,26 @@ ifneq ($(SKIP_DOCKER),true)
DOCKER_IS_PODMAN = \
$(shell ! docker -v 2>&1 | grep podman >/dev/null ; echo $$?)
ifeq "$(DOCKER_IS_PODMAN)" "1"
# Modify the SELinux label for the host directory to indicate
# that it can be shared with multiple containers. This is apparently
# only required for Podman, though it is also supported by Docker.
DOCKER_VOL_SUFFIX = :z
else
DOCKER_IS_ROOTLESS = \
$(shell ! docker info -f '{{println .SecurityOptions}}' | grep rootless >/dev/null ; echo $$?)
ifneq "$(DOCKER_IS_ROOTLESS)" "1"
# Rooted Docker requires this flag so that the files it creates are
# owned by the current user instead of root. Rootless docker does not
# require it, and Podman doesn't either since it is always rootless.
DOCKER_USER_ARG := --user $(shell id -u)
endif
endif

DOCKER_CMD = \
docker run --rm \
-v ${PWD}/$@.workdir:/build${DOCKER_VOL_SUFFIX} \
-w /build \
$(DOCKER_USER_ARG) \
${DOCKER_IMG} \
/bin/sh -c
DOCKER_QUOTE := "
Expand Down

0 comments on commit 9648e5e

Please sign in to comment.