|
| 1 | +// For format details, see https://containers.dev/implementors/json_reference/ |
| 2 | +{ |
| 3 | + "name": "Python 3 Developer Container", |
| 4 | + "build": { |
| 5 | + "dockerfile": "../Dockerfile", |
| 6 | + "target": "developer" |
| 7 | + }, |
| 8 | + "remoteEnv": { |
| 9 | + // Allow X11 apps to run inside the container |
| 10 | + "DISPLAY": "${localEnv:DISPLAY}", |
| 11 | + // Put things that allow it in the persistent cache |
| 12 | + "PRE_COMMIT_HOME": "/cache/pre-commit", |
| 13 | + "UV_CACHE_DIR": "/cache/uv", |
| 14 | + "UV_PYTHON_CACHE_DIR": "/cache/uv-python", |
| 15 | + // Make a venv that is specific for this workspace path as the cache is shared |
| 16 | + "UV_PROJECT_ENVIRONMENT": "/cache/venv-for${localWorkspaceFolder}", |
| 17 | + // Do the equivalent of "activate" the venv so we don't have to "uv run" everything |
| 18 | + "VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}", |
| 19 | + "PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}" |
| 20 | + }, |
| 21 | + "customizations": { |
| 22 | + "vscode": { |
| 23 | + // Set *default* container specific settings.json values on container create. |
| 24 | + "settings": { |
| 25 | + // Use the container's python by default |
| 26 | + "python.defaultInterpreterPath": "/cache/venv-for${localWorkspaceFolder}/bin/python", |
| 27 | + // Don't activate the venv as it is already in the PATH |
| 28 | + "python.terminal.activateEnvInCurrentTerminal": false, |
| 29 | + "python.terminal.activateEnvironment": false, |
| 30 | + // Workaround to prevent garbled python REPL in the terminal |
| 31 | + // https://github.com/microsoft/vscode-python/issues/25505 |
| 32 | + "python.terminal.shellIntegration.enabled": false |
| 33 | + }, |
| 34 | + // Add the IDs of extensions you want installed when the container is created. |
| 35 | + "extensions": [ |
| 36 | + "ms-python.python", |
| 37 | + "github.vscode-github-actions", |
| 38 | + "tamasfe.even-better-toml", |
| 39 | + "redhat.vscode-yaml", |
| 40 | + "ryanluker.vscode-coverage-gutters", |
| 41 | + "charliermarsh.ruff", |
| 42 | + "ms-azuretools.vscode-docker" |
| 43 | + ] |
| 44 | + } |
| 45 | + }, |
| 46 | + // Create the config folder for the bash-config feature and uv cache |
| 47 | + "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config", |
| 48 | + "runArgs": [ |
| 49 | + // Allow the container to access the host X11 display and EPICS CA |
| 50 | + // "--net=host", |
| 51 | + // Make sure SELinux does not disable with access to host filesystems like tmp |
| 52 | + "--security-opt=label=disable" |
| 53 | + ], |
| 54 | + "forwardPorts": [ |
| 55 | + 5173 |
| 56 | + ], |
| 57 | + "mounts": [ |
| 58 | + // Mount in the user terminal config folder so it can be edited |
| 59 | + { |
| 60 | + "source": "${localEnv:HOME}/.config/terminal-config", |
| 61 | + "target": "/user-terminal-config", |
| 62 | + "type": "bind" |
| 63 | + }, |
| 64 | + // Keep a persistent cross container cache for uv, pre-commit, and the venvs |
| 65 | + { |
| 66 | + "source": "devcontainer-shared-cache", |
| 67 | + "target": "/cache", |
| 68 | + "type": "volume" |
| 69 | + } |
| 70 | + ], |
| 71 | + // Mount the parent as /workspaces so we can pip install peers as editable |
| 72 | + "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", |
| 73 | + // After the container is created, recreate the venv then make pre-commit first run faster |
| 74 | + "postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks" |
| 75 | +} |
0 commit comments