Skip to content

Commit

Permalink
Run root Docker as the current user
Browse files Browse the repository at this point in the history
Reapplication of 3539eff but this time we only add the `--user` argument for root Docker. Rootless Docker behaves the same as Podman and doesn't need the `--user` flag; in fact it breaks builds if you add it.

I also added a comment for the `:z` flag.
  • Loading branch information
Timmmm committed Sep 25, 2024
1 parent e867a4e commit dfdf775
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 dfdf775

Please sign in to comment.