sparse-florist-94998
05/08/2025, 4:30 PMdef get_docker_platform():
env_platform = os.getenv("DOCKER_PLATFORM")
if env_platform:
return env_platform
arch = platform.machine()
if arch == "x86_64":
return "linux/amd64"
elif arch in ["aarch64", "arm64"]:
return "linux/aarch64"
else:
raise ValueError(f"Unsupported architecture: {arch}")
This function is working when no env variable is set, but when I try to set the env variable in my terminal it's ignored. do you have any idea how I could fix it?sparse-florist-94998
05/08/2025, 4:31 PMTARGET_BUILD_PLATFORM = get_docker_platform()
docker_image(
context_root="src",
build_platform=[TARGET_BUILD_PLATFORM],
)elegant-florist-94385
05/08/2025, 6:59 PMos.getenv in a build file or macro, but you can use env instead: https://www.pantsbuild.org/stable/reference/build-file-symbols/envsparse-florist-94998
05/08/2025, 7:11 PMelegant-florist-94385
05/09/2025, 10:06 AMenv to get the image tags from the environment.sparse-florist-94998
05/09/2025, 7:17 PM