Skip to content

Commit bf93968

Browse files
authored
Add dev container setup (#318)
1 parent 0dcaba0 commit bf93968

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "Iris",
3+
// Use the existing Dockerfile
4+
"build": {
5+
"dockerfile": "../docker/Dockerfile",
6+
"context": ".."
7+
},
8+
// Runs on the HOST before the container is created/started.
9+
// Creates a stable agent socket at ~/.ssh/ssh-agent.sock and optionally loads ~/.ssh/id_rsa.
10+
"initializeCommand": "bash -lc \"bash '${localWorkspaceFolder}/.devcontainer/ensure-ssh-agent.sh'\"",
11+
"runArgs": [
12+
"--name=${localEnv:USER}-iris-dev",
13+
"--network=host",
14+
"--device=/dev/kfd",
15+
"--device=/dev/dri",
16+
"--cap-add=SYS_PTRACE",
17+
"--group-add=video",
18+
"--security-opt=seccomp=unconfined",
19+
"--shm-size=16G",
20+
"--ipc=host",
21+
"--ulimit=memlock=-1",
22+
"--ulimit=stack=67108864"
23+
],
24+
"features": {
25+
"ghcr.io/devcontainers/features/common-utils:2": {
26+
"installZsh": true,
27+
"installOhMyZsh": true,
28+
"upgradePackages": false,
29+
"username": "automatic",
30+
"uid": "automatic",
31+
"gid": "automatic",
32+
"configureZshAsDefaultShell": false
33+
}
34+
},
35+
"mounts": [
36+
"source=${localEnv:HOME}/.ssh/ssh-agent.sock,target=/tmp/ssh-agent.sock,type=bind"
37+
],
38+
"remoteEnv": {
39+
"SSH_AUTH_SOCK": "/tmp/ssh-agent.sock"
40+
},
41+
"remoteUser": "vscode",
42+
"postStartCommand": "bash -lc 'set -e; if ! getent group video >/dev/null; then sudo groupadd -r video || true; fi; if ! getent group render >/dev/null; then sudo groupadd -r render || true; fi; sudo usermod -aG video,render vscode || true'",
43+
"updateRemoteUserUID": true
44+
}

.devcontainer/ensure-ssh-agent.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.
3+
4+
set -euo pipefail
5+
6+
# This script runs on the HOST (via devcontainer.json "initializeCommand").
7+
# It ensures there is an ssh-agent with a stable socket at:
8+
# ~/.ssh/ssh-agent.sock
9+
#
10+
# It also tries to load ~/.ssh/id_rsa if present.
11+
# If your key is passphrase-protected and you're non-interactive, it may fail silently.
12+
13+
SOCK="${HOME}/.ssh/ssh-agent.sock"
14+
15+
mkdir -p "${HOME}/.ssh"
16+
17+
if [[ -S "${SOCK}" ]]; then
18+
exit 0
19+
fi
20+
21+
rm -f "${SOCK}"
22+
ssh-agent -a "${SOCK}" -t 8h >/dev/null
23+
24+
if [[ -f "${HOME}/.ssh/id_rsa" ]]; then
25+
SSH_AUTH_SOCK="${SOCK}" ssh-add "${HOME}/.ssh/id_rsa" >/dev/null 2>&1 || true
26+
fi
27+
28+
SSH_AUTH_SOCK="${SOCK}" ssh-add -l >/dev/null 2>&1 || true

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,5 @@ __pycache__/
4545
*.pywz
4646
*.pyzw
4747
*.pyzwz
48+
49+
!.devcontainer/devcontainer.json

docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: MIT
2-
# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved.
2+
# Copyright (c) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
33

44
FROM rocm/pytorch:rocm7.1_ubuntu24.04_py3.13_pytorch_release_2.9.1
55

@@ -24,6 +24,9 @@ RUN apt-get update && \
2424
git wget ninja-build cmake python3-pip python3-dev build-essential && \
2525
rm -rf /var/lib/apt/lists/*
2626

27+
RUN groupadd -r video 2>/dev/null || true && \
28+
groupadd -r render 2>/dev/null || true
29+
2730
# Install Python packages with pip
2831
RUN pip3 install --upgrade pip && \
2932
pip3 install wheel jupyter

0 commit comments

Comments
 (0)