diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b7b99ad..7d77601 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -51,4 +51,3 @@ RUN \ uv pip install ipykernel eclipse-zenoh -p ~/.local/share/base && \ echo '. ~/.local/share/base/bin/activate' >> ~/.bashrc ENV VIRTUAL_ENV=/root/.local/share/base -CMD ["bash", "-c", "sudo rm /var/run/docker.pid; sudo dockerd"] diff --git a/.devcontainer/cpu/docker-compose.yaml b/.devcontainer/cpu/docker-compose.yaml deleted file mode 100644 index 0d3b537..0000000 --- a/.devcontainer/cpu/docker-compose.yaml +++ /dev/null @@ -1,15 +0,0 @@ -services: - ide: - build: - context: .. - dockerfile: ./Dockerfile - privileged: true # Docker-in-Docker needs this - cgroup: host # Allow setting resource constraints (e.g. memory, cpu) for containers - environment: - - RUST_BACKTRACE=1 # Display error trace on errors/panics - volumes: - - ${LOCAL_WORKSPACE_PATH}:${ENV_WORKSPACE_PATH} # source - - docker_data:/var/lib/docker # Docker image cache - - ${LOCAL_GIT_PATH}:${ENV_GIT_PATH} # Base Git worktree history -volumes: - docker_data: diff --git a/.devcontainer/cpu/devcontainer.json b/.devcontainer/devcontainer.json similarity index 73% rename from .devcontainer/cpu/devcontainer.json rename to .devcontainer/devcontainer.json index 6c66222..273ae3c 100644 --- a/.devcontainer/cpu/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,15 +1,29 @@ { "name": "Development-CPU-ONLY", - "dockerComposeFile": "./docker-compose.yaml", - "service": "ide", + "build": { + "dockerfile": "./Dockerfile" + }, + "postStartCommand": "sudo rm /var/run/docker.pid; sudo dockerd", "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "initializeCommand": ".devcontainer/make_env_file.py ${localWorkspaceFolder} ./cpu/", - "postStartCommand": "mkdir -p tests/.tmp && docker system prune -fa && docker volume prune -f", "hostRequirements": { "cpus": 2, "memory": "8gb", "storage": "32gb" }, + "remoteEnv": { + "RUST_BACKTRACE": "1" + }, + "capAdd": [ + "SYS_ADMIN" + ], + "privileged": true, + "runArgs": [ + "--cgroupns=host", + "--gpus=all" + ], + "mounts": [ + "source=docker_data,target=/var/lib/docker,type=volume" + ], "customizations": { "vscode": { "extensions": [ diff --git a/.devcontainer/gpu/devcontainer.json b/.devcontainer/gpu/devcontainer.json deleted file mode 100644 index 5a681dd..0000000 --- a/.devcontainer/gpu/devcontainer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Development-GPU", - "dockerComposeFile": "./docker-compose.yaml", - "service": "ide", - "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", - "initializeCommand": ".devcontainer/make_env_file.py ${localWorkspaceFolder} ./gpu/", - "postStartCommand": "mkdir -p tests/.tmp && docker system prune -fa && docker volume prune -f", - "hostRequirements": { - "cpus": 2, - "memory": "8gb", - "storage": "32gb" - }, - "customizations": { - "vscode": { - "extensions": [ - "rust-lang.rust-analyzer", // Rust VSCode features - "vadimcn.vscode-lldb", // Rust CodeLLDB debugger - "ms-vscode.hexeditor", // Binary preview in HEX - "tamasfe.even-better-toml", // *.toml language support - "eamodio.gitlens", // Git explorer in VSCode - "streetsidesoftware.code-spell-checker", // Catch spelling errors in docs - "GitHub.copilot-chat", // GitHub Copilot AI assistant - "tintinweb.graphviz-interactive-preview", // Graphviz DOT preview - "ms-python.python", // Python IDE - "ms-toolsai.jupyter", // Jupyter IDE - "ms-python.black-formatter" // Python code formatter - ] - } - }, - "features": { - "ghcr.io/meaningful-ooo/devcontainer-features/fish:2": {} // Fish shell - } -} diff --git a/.devcontainer/gpu/docker-compose.yaml b/.devcontainer/gpu/docker-compose.yaml deleted file mode 100644 index ba5d69f..0000000 --- a/.devcontainer/gpu/docker-compose.yaml +++ /dev/null @@ -1,22 +0,0 @@ -services: - ide: - build: - context: .. - dockerfile: ./Dockerfile - privileged: true # Docker-in-Docker needs this - cgroup: host # Allow setting resource constraints (e.g. memory, cpu) for containers - environment: - - RUST_BACKTRACE=1 # Display error trace on errors/panics - volumes: - - ${LOCAL_WORKSPACE_PATH}:${ENV_WORKSPACE_PATH} # source - - docker_data:/var/lib/docker # Docker image cache - - ${LOCAL_GIT_PATH}:${ENV_GIT_PATH} # Base Git worktree history - deploy: - resources: - reservations: - devices: - - driver: nvidia - count: all - capabilities: [ gpu ] -volumes: - docker_data: diff --git a/.devcontainer/make_env_file.py b/.devcontainer/make_env_file.py deleted file mode 100755 index 69c5a75..0000000 --- a/.devcontainer/make_env_file.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -# -# assumes git worktree was made using relative paths e.g. -# git worktree add ../dir-name branch-name --relative-paths -import sys -from pathlib import Path -from textwrap import dedent -import subprocess -from os.path import relpath - - -def make_config(local_workspace_path: Path): - env_workspace_path = Path(f"/workspaces/{local_workspace_path.name}") - local_git_path = Path( - subprocess.run( - "git rev-parse --path-format=absolute --git-common-dir".split(" "), - capture_output=True, - text=True, - ).stdout.strip() - ) - env_git_path = ( - env_workspace_path / ".git" - if local_workspace_path / ".git" == local_git_path - else ( - env_workspace_path - / relpath(local_git_path.parent, local_workspace_path) - / ".git" - ).resolve() - ) - - return dedent( - f""" - LOCAL_WORKSPACE_PATH={local_workspace_path} - ENV_WORKSPACE_PATH={env_workspace_path} - LOCAL_GIT_PATH={local_git_path} - ENV_GIT_PATH={env_git_path} - """ - ).strip() - - -if __name__ == "__main__": - local_workspace_path = Path(sys.argv[1]) - - with open(Path(__file__).absolute().parent / f"{sys.argv[2]}.env", "w") as f: - f.write(make_config(local_workspace_path))