fix(docker): use writable config for registry login
Python package / build (3.12.3) (pull_request) Successful in 2m9s
Python package / build (3.13) (pull_request) Successful in 2m21s
Python package / build (3.14) (pull_request) Successful in 2m43s

This commit is contained in:
hermes
2026-09-21 06:41:19 +00:00
parent 7ba38ff72b
commit 0bdec9f1ec
+13 -7
View File
@@ -3,6 +3,7 @@ import logging
import os
import re
import subprocess
import tempfile
from typing import Any, Callable, Dict
from urllib.parse import urlparse
@@ -26,7 +27,7 @@ def _secret_values() -> Dict[str, str]:
return values
def _registry_login(images: list[str]) -> None:
def _registry_login(images: list[str], env: Dict[str, str]) -> None:
values = _secret_values()
username = (
values.get("REGISTRY_USERNAME")
@@ -51,6 +52,7 @@ def _registry_login(images: list[str]) -> None:
input=password,
text=True,
check=True,
env=env,
stdout=subprocess.DEVNULL,
)
@@ -83,12 +85,16 @@ class DockerComposePull(AbstractStep[Dict[str, str]]):
yaml.safe_dump(compose, f)
try:
images = [svc.get("image", "") for svc in compose.get("services", {}).values()]
_registry_login([image for image in images if image])
subprocess.run(
["docker", "compose", "-f", tmp_path, "pull"],
check=True,
cwd=self.wd.progress(),
)
with tempfile.TemporaryDirectory() as docker_config:
env = os.environ.copy()
env["DOCKER_CONFIG"] = docker_config
_registry_login([image for image in images if image], env)
subprocess.run(
["docker", "compose", "-f", tmp_path, "pull"],
check=True,
cwd=self.wd.progress(),
env=env,
)
finally:
os.unlink(tmp_path)
return {name: svc.get("image", "") for name, svc in compose.get("services", {}).items()}