Skip to content

Commit 97a61ba

Browse files
KevinFairise2ofek
andauthored
Support selecting the architecture for Linux developer environments (#65)
Co-authored-by: Ofek Lev <ofekmeister@gmail.com>
1 parent 70b73ac commit 97a61ba

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/dda/env/dev/types/linux_container.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ class LinuxContainerConfig(DeveloperEnvironmentConfig):
4949
}
5050
),
5151
] = "zsh"
52+
arch: Annotated[
53+
str | None,
54+
msgspec.Meta(
55+
extra={
56+
"help": "The architecture to use e.g. `amd64` or `arm64`",
57+
}
58+
),
59+
] = None
5260

5361

5462
class LinuxContainer(DeveloperEnvironmentInterface[LinuxContainerConfig]):
@@ -81,7 +89,10 @@ def start(self) -> None:
8189
from dda.utils.retry import wait_for
8290

8391
if not self.config.no_pull:
84-
self.docker.wait(["pull", self.config.image], message=f"Pulling image: {self.config.image}")
92+
pull_command = ["pull", self.config.image]
93+
if self.config.arch is not None:
94+
pull_command.extend(("--platform", f"linux/{self.config.arch}"))
95+
self.docker.wait(pull_command, message=f"Pulling image: {self.config.image}")
8596

8697
self.shared_dir.ensure_dir()
8798
command = [
@@ -98,6 +109,9 @@ def start(self) -> None:
98109
"-e",
99110
AppEnvVars.TELEMETRY_API_KEY,
100111
]
112+
if self.config.arch is not None:
113+
command.extend(("--platform", f"linux/{self.config.arch}"))
114+
101115
for shared_shell_file in self.shell.collect_shared_files():
102116
unix_path = shared_shell_file.relative_to(self.global_shared_dir).as_posix()
103117
command.extend(("-v", f"{shared_shell_file}:{self.home_dir}/.shared/{unix_path}"))

tests/env/dev/types/test_linux_container.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def test_default_config(app):
3838
container = LinuxContainer(app=app, name="linux-container", instance="default")
3939

4040
assert msgspec.to_builtins(container.config) == {
41+
"arch": None,
4142
"cli": "docker",
4243
"clone": False,
4344
"image": "datadog/agent-dev-env-linux",

0 commit comments

Comments
 (0)