|
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, |
|
38 | 44 | } |
39 | 45 | }, |
40 | 46 | // Create the config folder for the bash-config feature and uv cache |
41 | | - // NOTE: The uv cache can get large, DLS users should read |
42 | | - // https://dev-guide.diamond.ac.uk/linux-user-environment/how-tos/disk-quota-troubleshooting |
43 | | - "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config ${localEnv:HOME}/.cache/uv", |
| 47 | + "initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config", |
44 | 48 | "runArgs": [ |
45 | 49 | // Allow the container to access the host X11 display and EPICS CA |
46 | 50 | "--net=host", |
|
54 | 58 | "target": "/user-terminal-config", |
55 | 59 | "type": "bind" |
56 | 60 | }, |
57 | | - // Keep a persistent cross container cache for uv |
| 61 | + // Keep a persistent cross container cache for uv, pre-commit, and the venvs |
58 | 62 | { |
59 | | - "source": "${localEnv:HOME}/.cache/uv", |
60 | | - "target": "/root/.cache/uv", |
61 | | - "type": "bind" |
62 | | - }, |
63 | | - // Use a volume mount for the uv venv so it is local to the container |
64 | | - { |
65 | | - "target": "/workspaces/${localWorkspaceFolderBasename}/.venv", |
| 63 | + "source": "devcontainer-shared-cache", |
| 64 | + "target": "/cache", |
66 | 65 | "type": "volume" |
67 | 66 | } |
68 | 67 | ], |
69 | 68 | // Mount the parent as /workspaces so we can pip install peers as editable |
70 | 69 | "workspaceMount": "source=${localWorkspaceFolder}/..,target=/workspaces,type=bind", |
71 | | - // After the container is created, install the python project in editable form |
72 | | - "postCreateCommand": "uv sync && uv run pre-commit install --install-hooks" |
| 70 | + // After the container is created, recreate the venv then make pre-commit first run faster |
| 71 | + "postCreateCommand": "uv venv --clear && uv sync && pre-commit install --install-hooks" |
73 | 72 | } |
0 commit comments