From ed765d86fdfc0d0d367720a507fdc1abe214b46a Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Mon, 11 May 2026 13:49:50 -0600 Subject: [PATCH] Suppress Docker build output when --quiet flag is set Pass `progress=False` to `docker.build` and `docker.buildx.bake` when the configured log level is `ERROR` or higher, so buildx progress output is captured instead of streamed to stderr. The default and `--verbose` log levels continue to use `progress="auto"`. Co-Authored-By: Claude Opus 4.7 (1M context) --- posit-bakery/posit_bakery/image/bake/bake.py | 10 +++++++++- posit-bakery/posit_bakery/image/image_target.py | 1 + posit-bakery/test/image/bake/test_bake.py | 1 + posit-bakery/test/image/test_image_target.py | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/posit-bakery/posit_bakery/image/bake/bake.py b/posit-bakery/posit_bakery/image/bake/bake.py index 07bf5d783..18c464e63 100644 --- a/posit-bakery/posit_bakery/image/bake/bake.py +++ b/posit-bakery/posit_bakery/image/bake/bake.py @@ -1,3 +1,4 @@ +import logging import os from pathlib import Path from typing import Annotated, Any @@ -7,6 +8,7 @@ from posit_bakery.config.image.build_os import TargetPlatform, DEFAULT_PLATFORMS from posit_bakery.image.image_target import ImageTarget +from posit_bakery.settings import SETTINGS class BakeGroup(BaseModel): @@ -281,7 +283,13 @@ def build( _set = self._set_opts_dict_to_str(_set) python_on_whales.docker.buildx.bake( - files=[self.bake_file.name], load=load, push=push, pull=pull, cache=cache, set=_set + files=[self.bake_file.name], + load=load, + push=push, + pull=pull, + cache=cache, + set=_set, + progress=False if SETTINGS.log_level >= logging.ERROR else "auto", ) if clean_bakefile: self.remove() diff --git a/posit-bakery/posit_bakery/image/image_target.py b/posit-bakery/posit_bakery/image/image_target.py index fa00be158..9cfef799c 100644 --- a/posit-bakery/posit_bakery/image/image_target.py +++ b/posit-bakery/posit_bakery/image/image_target.py @@ -624,6 +624,7 @@ def build( platforms=platforms or self.image_os.platforms, target=self.build_target, secrets=[s.as_cli_option() for s in self.resolved_build_secrets], + progress=False if SETTINGS.log_level >= logging.ERROR else "auto", ) except python_on_whales.exceptions.DockerException as e: raise BakeryToolRuntimeError( diff --git a/posit-bakery/test/image/bake/test_bake.py b/posit-bakery/test/image/bake/test_bake.py index 51df7a9cc..351d57beb 100644 --- a/posit-bakery/test/image/bake/test_bake.py +++ b/posit-bakery/test/image/bake/test_bake.py @@ -329,6 +329,7 @@ def test_build_args( "pull": False, "cache": True, "set": {}, + "progress": "auto", } with patch("python_on_whales.docker.buildx.bake") as mock_bake: diff --git a/posit-bakery/test/image/test_image_target.py b/posit-bakery/test/image/test_image_target.py index 28360e900..7e3e581e6 100644 --- a/posit-bakery/test/image/test_image_target.py +++ b/posit-bakery/test/image/test_image_target.py @@ -637,6 +637,7 @@ def test_build_args(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": None, "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -670,6 +671,7 @@ def test_build_args_with_build_args(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": None, "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -699,6 +701,7 @@ def test_build_args_cache_registry(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": None, "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -728,6 +731,7 @@ def test_build_args_cache_registry_push(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": None, "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -756,6 +760,7 @@ def test_build_args_temp_registry(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": None, "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -785,6 +790,7 @@ def test_build_args_with_target(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": "my-stage", "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -814,6 +820,7 @@ def test_build_args_with_target_from_image(self, basic_standard_image_target): "platforms": ["linux/amd64"], "target": "image-stage", "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -844,6 +851,7 @@ def test_build_args_with_target_version_overrides_image(self, basic_standard_ima "platforms": ["linux/amd64"], "target": "version-stage", "secrets": [], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: @@ -912,6 +920,7 @@ def test_build_args_with_secrets(self, basic_standard_image_target, monkeypatch) "platforms": ["linux/amd64"], "target": None, "secrets": ["id=github_token,env=GITHUB_TOKEN"], + "progress": "auto", } with patch("python_on_whales.docker.build") as mock_build: