2626import subprocess
2727import click
2828from pathlib import Path
29+ from typing import Any
2930from stack_orchestrator .opts import opts
3031from stack_orchestrator .util import include_exclude_check , stack_is_external , error_exit
3132from 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
6568def 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 :
0 commit comments