|
8 | 8 | "remoteEnv": { |
9 | 9 | // Allow X11 apps to run inside the container |
10 | 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}", |
11 | 17 | // Do the equivalent of "activate" the venv so we don't have to "uv run" everything |
12 | | - "VIRTUAL_ENV": "/workspaces/${localWorkspaceFolderBasename}/.venv", |
13 | | - "PATH": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin:${containerEnv:PATH}" |
| 18 | + "VIRTUAL_ENV": "/cache/venv-for${localWorkspaceFolder}", |
| 19 | + "PATH": "/cache/venv-for${localWorkspaceFolder}/bin:${containerEnv:PATH}" |
14 | 20 | }, |
15 | 21 | "customizations": { |
16 | 22 | "vscode": { |
17 | 23 | // Set *default* container specific settings.json values on container create. |
18 | 24 | "settings": { |
19 | 25 | // Use the container's python by default |
20 | | - "python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python", |
| 26 | + "python.defaultInterpreterPath": "/cache/venv-for${localWorkspaceFolder}/bin/python", |
21 | 27 | // Don't activate the venv as it is already in the PATH |
22 | 28 | "python.terminal.activateEnvInCurrentTerminal": false, |
23 | 29 | "python.terminal.activateEnvironment": false, |
|
47 | 53 | } |
48 | 54 | }, |
49 | 55 | // Create the config folder for the bash-config feature and uv cache |
50 | | - // NOTE: The uv cache can get large, DLS users should read |
51 | | - // https://dev-guide.diamond.ac.uk/linux-user-environment/how-tos/disk-quota-troubleshooting |
52 | | - "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config ${localEnv:HOME}/.cache/uv", |
| 56 | + "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config", |
53 | 57 | "runArgs": [ |
54 | 58 | // Allow the container to access the host X11 display and EPICS CA |
55 | 59 | "--net=host", |
|
63 | 67 | "target": "/user-terminal-config", |
64 | 68 | "type": "bind" |
65 | 69 | }, |
66 | | - // Keep a persistent cross container cache for uv |
| 70 | + // Keep a persistent cross container cache for uv, pre-commit, and the venvs |
67 | 71 | { |
68 | | - "source": "${localEnv:HOME}/.cache/uv", |
69 | | - "target": "/root/.cache/uv", |
70 | | - "type": "bind" |
71 | | - }, |
72 | | - // Use a volume mount for the uv venv so it is local to the container |
73 | | - { |
74 | | - "target": "/workspaces/${localWorkspaceFolderBasename}/.venv", |
| 72 | + "source": "devcontainer-shared-cache", |
| 73 | + "target": "/cache", |
75 | 74 | "type": "volume" |
76 | 75 | } |
77 | 76 | ], |
78 | 77 | // Mount the parent as /workspaces so we can pip install peers as editable |
79 | 78 | "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", |
80 | | - // After the container is created, install the python project in editable form |
81 | | - "postCreateCommand": "uv sync && uv run pre-commit install --install-hooks" |
| 79 | + // After the container is created, recreate the venv then make pre-commit first run faster |
| 80 | + "postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks" |
82 | 81 | } |
0 commit comments