{
    "$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.schema.json",
    "copyright": [
        "SPDX-FileCopyrightText: Copyright (c) {{ current_year }} NVIDIA CORPORATION & AFFILIATES. All rights reserved.",
        "SPDX-License-Identifier: Apache-2.0"
    ],
    "name": "Dynamo {{ framework.upper() }} Dev Container",
    "remoteUser": "dynamo", // Matches our container user
    "updateRemoteUserUID": true, // Updates the UID of the remote user to match the host user, avoids permission errors
    "image": "dynamo:latest-{{ framework }}-local-dev", // Use the latest {{ framework.upper() }} dev image
    "runArgs": [
        "--gpus=all",
        "--network=host",
        "--ipc=host",
        "--cap-add=SYS_PTRACE",
        "--shm-size=10G",
        "--ulimit=memlock=-1",
        "--ulimit=stack=67108864",
        "--ulimit=nofile=65536:65536"
    ],
    "customizations": {
        "vscode": {
            "extensions": [
                "ms-python.python",
                "ms-python.vscode-pylance",
                "rust-lang.rust-analyzer"
            ],
            "settings": {
                // Disable automatic copying of .gitconfig to avoid errors
                "dev.containers.copyGitConfig": false,
                "terminal.integrated.defaultProfile.linux": "bash",
                "terminal.integrated.cwd": "/workspace",

                "python.defaultInterpreterPath": "/opt/dynamo/venv/bin/python",
                "python.linting.enabled": true,

                "rust-analyzer.memoryLimit": 4096, // larger memory limit to reduce latency
                "rust-analyzer.checkOnSave.command": "clippy",
                "rust-analyzer.checkOnSave.enable": true,
                "rust-analyzer.cargo.buildScripts.enable": true,
                "rust-analyzer.cargo.targetDir": "/workspace/target",
                "rust-analyzer.procMacro.enable": true,
                "rust-analyzer.completion.autoimport.enable": true,

                // Enhanced rust-analyzer configuration
                "rust-analyzer.linkedProjects": [
                    "Cargo.toml",
                    "lib/runtime/Cargo.toml",
                    "lib/llm/Cargo.toml",
                    "lib/tokens/Cargo.toml",
                    "lib/bindings/python/Cargo.toml",
                ],
                "files.trimTrailingWhitespace": true,
                "files.insertFinalNewline": true
            }
        }
    },
    "workspaceFolder": "/workspace",
    "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind,consistency=cached",
    "userEnvProbe": "interactiveShell",
    "postCreateCommand": "/bin/bash /workspace/.devcontainer/post-create.sh", // Runs cargo build and pip installs packages
    "remoteEnv": {
        // Optional convenience tokens passed from host. SSH agent is forwarded via your IDE setting, not here by default.
        "GITHUB_TOKEN": "${localEnv:GITHUB_TOKEN}",
        "HF_TOKEN": "${localEnv:HF_TOKEN}"
        // "SSH_AUTH_SOCK": "${env:SSH_AUTH_SOCK}" // Optional: only if you also bind-mount the socket path
    },
    "mounts": [
        // These are for convenience, so that the history and pre-commit cache are persisted between sessions
        "source=dynamo-bashhistory,target=/home/dynamo/.commandhistory,type=volume",
        "source=dynamo-precommit-cache,target=/home/dynamo/.cache/pre-commit,type=volume",
        // Default mounts
        "source=/tmp/,target=/tmp/,type=bind"
        // Uncomment this to reuse your Hugging Face cache
        //"source=${localEnv:HOME}/.cache/huggingface,target=/home/dynamo/.cache/huggingface,type=bind"
    ]
}
