Skip to content

Commit cd93016

Browse files
feat: Set docker platform from DOCKER_DEFAULT_PLATFORM env variable (#129)
* If the environment variable DOCKER_DEFAULT_PLATFORM exists use it to set the --platform option for 'docker run'. This is required to be able to run on other platforms than the native host's with emulation. - c.f. https://docs.docker.com/engine/reference/commandline/cli/#environment-variables
1 parent 99528ea commit cd93016

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/recastatlas/backends/docker.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def setup_docker():
3838
"/var/run/docker.sock:/var/run/docker.sock",
3939
]
4040

41+
# Set from DOCKER_DEFAULT_PLATFORM environment variable if it exists
42+
if "platform" in config.backends[backend]:
43+
if _platform := config.backends[backend]["platform"]:
44+
command += ["--platform", _platform]
45+
4146
if "cvmfs" in config.backends[backend]:
4247
command += [
4348
"-e",

src/recastatlas/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def backends(self):
4646
"image": conf_from_env(
4747
"RECAST_DOCKER_IMAGE", "recast/recastatlas:v0.3.0"
4848
),
49+
"platform": conf_from_env("DOCKER_DEFAULT_PLATFORM"),
4950
"cvmfs": {"location": "/cvmfs", "propagation": "rprivate"},
5051
"reg": {
5152
"user": conf_from_env("RECAST_REGISTRY_USERNAME"),

0 commit comments

Comments
 (0)