Skip to content

Commit 63daa1c

Browse files
authored
Change uv caching approach (#19)
Now control uv cache location with enviroment variables
1 parent c895143 commit 63daa1c

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

.devcontainer.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
},
77
"remoteEnv": {
88
// Allow X11 apps to run inside the container
9-
"DISPLAY": "${localEnv:DISPLAY}"
9+
"DISPLAY": "${localEnv:DISPLAY}",
10+
// Put things that allow it in the persistent cache
11+
"UV_CACHE_DIR": "/cache/uv",
12+
"UV_PYTHON_CACHE_DIR": "/cache/uv-python"
1013
},
11-
// Create the config folder for the user modifiable terminal-config and the uv cache
12-
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config ${localEnv:HOME}/.cache/uv",
14+
// Create the config folder for the user modifiable terminal-config
15+
"initializeCommand": "mkdir -p ${localEnv:HOME}/.config/terminal-config",
1316
"runArgs": [
1417
// Allow the container to access the host X11 display and EPICS CA
1518
"--net=host",
@@ -23,11 +26,11 @@
2326
"target": "/user-terminal-config",
2427
"type": "bind"
2528
},
26-
// Keep a persistent cross container cache for uv
29+
// Keep a persistent cross container cache
2730
{
28-
"source": "${localEnv:HOME}/.cache/uv",
29-
"target": "/root/.cache/uv",
30-
"type": "bind"
31+
"source": "devcontainer-shared-cache",
32+
"target": "/cache",
33+
"type": "volume"
3134
}
3235
],
3336
// Mount the parent as /workspaces so we can pip install peers as editable

Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,3 @@ RUN /root/terminal-config/ensure-user-terminal-config.sh && \
4646
# Install uv using the official image
4747
# See https://docs.astral.sh/uv/guides/integration/docker/#installing-uv
4848
COPY --from=ghcr.io/astral-sh/uv:0.9 /uv /uvx /bin/
49-
50-
# We recommend mounting in a cache for uv, so silence warnings about it being on a different volume
51-
# and cache python interpreter downloads in the same directory
52-
# https://docs.astral.sh/uv/guides/integration/docker/#caching
53-
ENV UV_LINK_MODE=copy
54-
ENV UV_PYTHON_CACHE_DIR=/root/.cache/uv/python

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ History is also stored in this directory, in `.bash_eternal_history` and `.zsh_e
4646

4747
See [this repo's `.devcontainer.json`](./.devcontainer.json) for an example on how to use as a devcontainer. Or clone this repo, open in vscode and click "reopen in container"
4848

49+
If you are considering using this for a pure python project devcontainer, consider using https://github.com/DiamondLightSource/python-copier-template
50+
4951
## How to use in the build stage of a Dockerfile
5052

5153
If you are using this during the build stage of a Dockerfile, then you should select the upstream `ubuntu` container for the runtime.

0 commit comments

Comments
 (0)