diff mbox series

[7/8] tools/build-docs-container: allow passing extra args to $OCI run

Message ID 20251222-concurrent-safety-v1-7-e3d86e44cd38@bootlin.com
State New
Headers show
Series Parallel docs build improvements | expand

Commit Message

Antonin Godard Dec. 22, 2025, 12:27 p.m. UTC
Add a OCI_RUN_EXTRA_ARGS env variable to allow customizing the arguments
passed to the podman/docker run command. For example:

  export OCI_RUN_EXTRA_ARGS="--env=SPHINXOPTS=-W --keep-going -j1"

To limit the number of threads used by Sphinx. This is especially useful
for parallel builds.

Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 documentation/tools/build-docs-container | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Quentin Schulz Jan. 12, 2026, 1:20 p.m. UTC | #1
Hi Antonin,

On 12/22/25 1:27 PM, Antonin Godard wrote:
> Add a OCI_RUN_EXTRA_ARGS env variable to allow customizing the arguments
> passed to the podman/docker run command. For example:
> 
>    export OCI_RUN_EXTRA_ARGS="--env=SPHINXOPTS=-W --keep-going -j1"
> 
> To limit the number of threads used by Sphinx. This is especially useful
> for parallel builds.
> 

How about exporting host variables inside the container? That would 
allow to not have to add OCI_RUN_EXTRA_ARGS when comparing native with 
container's output.

Something like

args_run+=(--env SPHINXOPTS)
args_run+=(--env SPHINXBUILD)
args_run+=(--env VALEOPTS)
args_run+=(--env VALEDOCS)
args_run+=(--env SPHINXLINTDOCS)

(not tested).

Also, you can already do that by simply doing

documentation/tools/build-docs-container leap:15.6 SPHINXOPTS=--bla html

for example.

FYI, I've realized that our "which CONTAINERCMD" doesn't actually work 
when you have podman-docker installed. I had an alias in my zshrc 
setting docker to podman directly... I need to figure out if there's a 
way to detect whether podman-docker is installed and in that case use 
podman instead of docker. The user mapping doesn't seem to work though 
(using the docker configuration in our script, with podman-docker 
installed, so effectively using rootless podman but with docker 
arguments). Seems like the owner of files within the container is not 
mapped to a host container (all owned by root in the container, which 
seems to be the default when a user id doesn't map to anything known on 
the host).

/usr/bin/docker is a shell script exec'ing podman with the same args but 
the naive check on whether it's a shell script is probably a bad idea, 
as nothing guarantees it is a shell script on all distros or that docker 
won't suddenly become a shell script itself.

Cheers,
Quentin
diff mbox series

Patch

diff --git a/documentation/tools/build-docs-container b/documentation/tools/build-docs-container
index 7a5191710..c5cdd9c4c 100755
--- a/documentation/tools/build-docs-container
+++ b/documentation/tools/build-docs-container
@@ -25,6 +25,7 @@  CONTAINERCMD=${CONTAINERCMD:-docker}
 DOCS_DIR="$SCRIPT_DIR/../.."
 INCLUDE_ESSENTIAL_PACKAGES=${INCLUDE_ESSENTIAL_PACKAGES:-0}
 RUN_NON_INTERACTIVE="${RUN_NON_INTERACTIVE:-0}"
+OCI_RUN_EXTRA_ARGS="${OCI_RUN_EXTRA_ARGS:-}"
 
 function usage()
 {
@@ -69,6 +70,8 @@  $0 OCI_IMAGE [make arguments...]
 
    - RUN_NON_INTERACTIVE: when set to 1, allow the '\$OCI run' command to be run
      non-interactively, without a tty.
+
+   - OCI_RUN_EXTRA_ARGS: extra arguments to pass to the '\$OCI run' command.
 "
 }
 
@@ -210,6 +213,9 @@  main ()
     )
   fi
 
+  # Extra arguments.
+  [ -n "$OCI_RUN_EXTRA_ARGS" ] && args_run+=( "${OCI_RUN_EXTRA_ARGS}" )
+
   $OCI run \
     "${args_run[@]}" \
     "$image_sha" \