Describe the bug
Build arguments defined inside the --podman-build-args flag do not maintain proper CLI precedence over build arguments defined in compose.yaml. The parameters passed via --podman-build-args are appended before the ones evaluated from compose.yaml, causing the compose.yaml values to override the CLI values (since the last flag wins in Podman/Docker CLI evaluation).
To Reproduce
Steps to reproduce the behavior:
- Define a
compose.yaml with a build argument set to 0:
services:
app:
build:
context: .
args:
CUSTOM_VAR: 0
-
Run podman-compose overriding the argument via --podman-build-args:
podman-compose --podman-build-args="--build-arg CUSTOM_VAR=1" build
-
Observe the underlying podman build command generated and executed by podman-compose:
podman build --build-arg CUSTOM_VAR=1 --build-arg CUSTOM_VAR=0 .
Here, CUSTOM_VAR=1 (from CLI) is litterally placed before CUSTOM_VAR=0 (from compose.yaml) without being evaluated. As a result, CUSTOM_VAR=0 overrides CUSTOM_VAR=1, effectively violating the expected CLI > compose.yaml precedence.
-
Run podman-compose using the argument --build-arg:
podman-compose build --build-arg CUSTOM_VAR=1
-
The output is correctly evaluated:
podman build --build-arg CUSTOM_VAR=1 .
Expected behavior
The precedence hierarchy for build arguments should consistently be:
- CLI Flags (Highest priority)
compose.yaml / docker-compose.yml
- Dockerfile / Containerfile (Lowest priority)
Any --build-arg supplied via the CLI (whether passed directly or encapsulated via --podman-build-args) should take precedence over values defined inside the compose.yaml file.
Actual behavior
When passing a build argument using --podman-build-args="--build-arg VAR=val", podman-compose injects the flag early into the generated podman build command. It then appends the arguments parsed from compose.yaml after it.
Since Podman evaluates multiple --build-arg declarations sequentially and applies the last one, the value from compose.yaml wins over the CLI value provided inside --podman-build-args.
MAYBE this probably affects also other evaluation topics like the one reported here: #1174
Describe the bug
Build arguments defined inside the
--podman-build-argsflag do not maintain proper CLI precedence over build arguments defined incompose.yaml. The parameters passed via--podman-build-argsare appended before the ones evaluated fromcompose.yaml, causing thecompose.yamlvalues to override the CLI values (since the last flag wins in Podman/Docker CLI evaluation).To Reproduce
Steps to reproduce the behavior:
compose.yamlwith a build argument set to 0:Run
podman-composeoverriding the argument via--podman-build-args:podman-compose --podman-build-args="--build-arg CUSTOM_VAR=1" buildObserve the underlying
podmanbuild command generated and executed bypodman-compose:podman build --build-arg CUSTOM_VAR=1 --build-arg CUSTOM_VAR=0 .Here,
CUSTOM_VAR=1(from CLI) is litterally placed beforeCUSTOM_VAR=0(fromcompose.yaml) without being evaluated. As a result,CUSTOM_VAR=0overridesCUSTOM_VAR=1, effectively violating the expected CLI >compose.yamlprecedence.Run
podman-composeusing the argument--build-arg:podman-compose build --build-arg CUSTOM_VAR=1The output is correctly evaluated:
podman build --build-arg CUSTOM_VAR=1 .Expected behavior
The precedence hierarchy for build arguments should consistently be:
compose.yaml / docker-compose.ymlAny
--build-argsupplied via the CLI (whether passed directly or encapsulated via--podman-build-args) should take precedence over values defined inside thecompose.yamlfile.Actual behavior
When passing a build argument using
--podman-build-args="--build-arg VAR=val", podman-compose injects the flag early into the generated podman build command. It then appends the arguments parsed fromcompose.yamlafter it.Since
Podmanevaluates multiple--build-argdeclarations sequentially and applies the last one, the value fromcompose.yamlwins over the CLI value provided inside--podman-build-args.MAYBE this probably affects also other evaluation topics like the one reported here: #1174