Skip to content

Commit 124c44c

Browse files
committed
add docs entry
1 parent a9faa2e commit 124c44c

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

docs/notes/2.32.x.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ The option `[docker].push_on_package` can be used to prevent Docker images from
8181

8282
Running `pants publish` on a `docker_image` target with `skip_push=True` will no longer package the `docker_image`.
8383

84+
The option `[docker].build_extra_options` or/and the `build_extra_options` field of `docker_image` targets can now be used to pass extra options to docker build or podman build. Make sure that the options are understood by the tool.
85+
For example, you can now set `build_extra_options=["--no-cache"]` to do not use existing cached images for the container build.
86+
87+
Fields that are already present in the docker image target are surpressed by the extra options when they conflict.
88+
For example, if you set `build_extra_options=["--pull"]`, the `pull` field of the docker image target will be ignored.
89+
8490
#### Helm
8591

8692
When `pants publish` is invoked, Pants will now skip packaging for `helm_chart` targets if either `skip_push=True` or the target has no registries.

src/python/pants/backend/docker/goals/package_image.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ def get_build_options(
429429
if global_build_no_cache_option:
430430
extra_options = extra_options + ("--no-cache",)
431431

432-
# Append extra options last so that they take precedence over the structured fields above.
433432
yield from extra_options
434433

435434

src/python/pants/backend/docker/goals/package_image_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,7 +3006,7 @@ def check_build_process(result: DockerImageBuildProcess):
30063006

30073007

30083008
def test_extra_build_options_global_and_target_merged(rule_runner: RuleRunner) -> None:
3009-
"""Global options come first; per-target options come last."""
3009+
"""Global options and per-target options should be merged correctly."""
30103010
rule_runner.set_options(
30113011
[],
30123012
env={
@@ -3072,7 +3072,7 @@ def test_global_extra_options_overridden_by_target_extra_options(
30723072
rule_runner: RuleRunner,
30733073
) -> None:
30743074
"""When both global and target extra options specify the same flag, the target wins
3075-
(it comes last) and the global does not appear."""
3075+
and the global does not appear."""
30763076
rule_runner.set_options(
30773077
[],
30783078
env={

0 commit comments

Comments
 (0)