Skip to content

Commit b5b6926

Browse files
committed
Merge branch 'build-forward-vars' into vaasl-deploy
2 parents 27ee95d + ba1fef5 commit b5b6926

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

stack_orchestrator/build/build_containers.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import subprocess
2727
import click
2828
from pathlib import Path
29+
from typing import Any
2930
from stack_orchestrator.opts import opts
3031
from stack_orchestrator.util import include_exclude_check, stack_is_external, error_exit
3132
from stack_orchestrator.base import get_npm_registry_url
@@ -42,7 +43,7 @@ def make_container_build_env(dev_root_path: str,
4243
debug: bool,
4344
force_rebuild: bool,
4445
extra_build_args: str):
45-
container_build_env = {
46+
command_env: dict[str, Any] = {
4647
"CERC_NPM_REGISTRY_URL": get_npm_registry_url(),
4748
"CERC_GO_AUTH_TOKEN": config("CERC_GO_AUTH_TOKEN", default=""),
4849
"CERC_NPM_AUTH_TOKEN": config("CERC_NPM_AUTH_TOKEN", default=""),
@@ -52,14 +53,16 @@ def make_container_build_env(dev_root_path: str,
5253
"CERC_HOST_GID": f"{os.getgid()}",
5354
"DOCKER_BUILDKIT": config("DOCKER_BUILDKIT", default="0")
5455
}
55-
container_build_env.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
56-
container_build_env.update({"CERC_FORCE_REBUILD": "true"} if force_rebuild else {})
57-
container_build_env.update({"CERC_CONTAINER_EXTRA_BUILD_ARGS": extra_build_args} if extra_build_args else {})
58-
docker_host_env = os.getenv("DOCKER_HOST")
59-
if docker_host_env:
60-
container_build_env.update({"DOCKER_HOST": docker_host_env})
56+
command_env.update({"CERC_SCRIPT_DEBUG": "true"} if debug else {})
57+
command_env.update({"CERC_FORCE_REBUILD": "true"} if force_rebuild else {})
58+
command_env.update({"CERC_CONTAINER_EXTRA_BUILD_ARGS": extra_build_args} if extra_build_args else {})
6159

62-
return container_build_env
60+
forwarded_vars = ("DOCKER_HOST", "BUILDKIT_PROGRESS", "http_proxy", "https_proxy")
61+
for var in forwarded_vars:
62+
if value := config(var, default=None):
63+
command_env[var] = value
64+
65+
return command_env
6366

6467

6568
def process_container(build_context: BuildContext) -> bool:
@@ -100,11 +103,11 @@ def process_container(build_context: BuildContext) -> bool:
100103
"default-build.sh") + f" {default_container_tag} {repo_dir_or_build_dir}"
101104
if not opts.o.dry_run:
102105
# No PATH at all causes failures with podman.
103-
if "PATH" not in build_context.container_build_env:
104-
build_context.container_build_env["PATH"] = os.environ["PATH"]
106+
if "PATH" not in build_context.command_env:
107+
build_context.command_env["PATH"] = os.environ["PATH"]
105108
if opts.o.verbose:
106-
print(f"Executing: {build_command} with environment: {build_context.container_build_env}")
107-
build_result = subprocess.run(build_command, shell=True, env=build_context.container_build_env)
109+
print(f"Executing: {build_command} with environment: {build_context.command_env}")
110+
build_result = subprocess.run(build_command, shell=True, env=build_context.command_env)
108111
if opts.o.verbose:
109112
print(f"Return code is: {build_result.returncode}")
110113
if build_result.returncode != 0:

stack_orchestrator/build/build_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class BuildContext:
2424
stack: str
2525
container: str
2626
container_build_dir: Path
27-
container_build_env: Mapping[str,str]
27+
# Environment for the docker build command
28+
command_env: Mapping[str,str]
2829
dev_root_path: str
2930

0 commit comments

Comments
 (0)