Skip to content

Commit f8a698d

Browse files
author
root
committed
split devcontainer for win and linux
1 parent 8a3ddb1 commit f8a698d

File tree

5 files changed

+72
-38
lines changed

5 files changed

+72
-38
lines changed

.devcontainer/Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
3939
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics
4040

4141
# Create and set proper permissions for workspace directory
42-
RUN mkdir -p /workspace && chown -R $USERNAME:$USERNAME /workspace
42+
RUN mkdir -p /workspace && chown -R $USERNAME:$USERNAME /workspace && sudo chmod -R 777 /workspace
4343

4444
# Create virtual environment with proper permissions
4545
ENV VIRTUAL_ENV=/home/vscode/venv
@@ -63,9 +63,4 @@ COPY --chown=$USERNAME:$USERNAME pyproject.toml .
6363
RUN pip install --no-cache-dir -e ".[test,gpu]"
6464

6565
# Set final working directory and ensure proper permissions
66-
WORKDIR /workspace
67-
68-
# Add write permissions for workspace and potential mount points
69-
RUN sudo chmod -R 777 /workspace && \
70-
sudo mkdir -p /workspaces && \
71-
sudo chown -R $USERNAME:$USERNAME /workspaces
66+
WORKDIR /workspace

.devcontainer/devcontainer.linux.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"name": "Crazyflow Development",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": ".."
6+
},
7+
"customizations": {
8+
"vscode": {
9+
"extensions": [
10+
"ms-python.python",
11+
"ms-python.pylance",
12+
"charliermarsh.ruff",
13+
"ms-vscode.test-adapter-converter",
14+
"ms-python.pytest-adapter",
15+
"nvidia.nsight-vscode-edition",
16+
"ms-azuretools.vscode-docker",
17+
"ms-toolsai.jupyter-renderers",
18+
"ms-toolsai.jupyter",
19+
"ms-toolsai.jupyter-keymap"
20+
],
21+
"settings": {
22+
"python.defaultInterpreterPath": "/home/vscode/venv/bin/python",
23+
"python.testing.pytestEnabled": true, // test framework
24+
"python.testing.pytestArgs": [
25+
"-m",
26+
"not render"
27+
],
28+
"python.testing.unittestEnabled": false, // test framework
29+
"python.testing.nosetestsEnabled": false, // test framework
30+
"editor.formatOnSave": true,
31+
"editor.codeActionsOnSave": {
32+
"source.fixAll.ruff": true,
33+
"source.organizeImports.ruff": true
34+
},
35+
"[python]": {
36+
"editor.defaultFormatter": "charliermarsh.ruff",
37+
"editor.formatOnSave": true,
38+
"editor.rulers": [
39+
100
40+
]
41+
}
42+
}
43+
}
44+
},
45+
"containerEnv": {
46+
"DISPLAY": "${localEnv:DISPLAY}",
47+
"XAUTHORITY": "${localEnv:XAUTHORITY}"
48+
},
49+
"runArgs": [
50+
"--gpus=all",
51+
"--interactive",
52+
"--net=host",
53+
"--ipc=host",
54+
"--runtime=nvidia"
55+
],
56+
"postCreateCommand": "python -m pip install -e '.[test,gpu]'",
57+
"remoteUser": "vscode"
58+
}

.devcontainer/devcontainer.json renamed to .devcontainer/devcontainer.wsl2.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,25 @@
4242
}
4343
}
4444
},
45-
"mounts": [], // mounts are configured in setup-mounts.sh
46-
"postStartCommand": "chmod +x /workspaces/crazyflow/scripts/setup-mounts.sh && /workspaces/crazyflow/scripts/setup-mounts.sh",
47-
// set environment variables inside container. localEnv copies from host.
48-
"containerEnv": {
45+
// mounts required for WSL2 X11
46+
"mounts": [
47+
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind",
48+
"source=/mnt/wslg,target=/mnt/wslg,type=bind",
49+
"source=/usr/lib/wsl,target=/usr/lib/wsl,type=bind"
50+
],"containerEnv": {
4951
"DISPLAY": "${localEnv:DISPLAY}",
5052
"XAUTHORITY": "${localEnv:XAUTHORITY}",
51-
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}", // windows
52-
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}", // windows
53-
"PULSE_SERVER": "${localEnv:PULSE_SERVER}" // windows
53+
"WAYLAND_DISPLAY": "${localEnv:WAYLAND_DISPLAY}", // WSL2
54+
"XDG_RUNTIME_DIR": "${localEnv:XDG_RUNTIME_DIR}", // WSL2
55+
"PULSE_SERVER": "${localEnv:PULSE_SERVER}" // WSL2
5456
},
55-
// clargs passed to the container
5657
"runArgs": [
5758
"--gpus=all",
5859
"--interactive",
5960
"--net=host",
6061
"--ipc=host",
6162
"--runtime=nvidia"
6263
],
63-
"postCreateCommand": "pip install -e '.[test,gpu]'", //'.[test,gpu]'
64+
"postCreateCommand": "python -m pip install -e '.[test,gpu]'",
6465
"remoteUser": "vscode"
6566
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ saves
1010
build
1111
.venv
1212
!/.devcontainer/devcontainer.json
13+
!/.devcontainer/devcontainer.linux.json
14+
!/.devcontainer/devcontainer.wsl2.json
1315
!/.vscode/launch.json

scripts/setup-mounts.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)