trevorpfiz commited on
Commit
275afd3
·
1 Parent(s): dc751ef

Spaces: drop BuildKit cache mounts; use user HOME cache for uv; avoid permission denied on /home/user/.cache/uv

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -6
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ghcr.io/astral-sh/uv:python3.11-bookworm-slim
2
 
3
  ARG USERNAME=user
4
  ARG USER_UID=1000
@@ -19,17 +19,15 @@ USER ${USERNAME}
19
  # Writable UV cache for non-root user
20
  ENV UV_CACHE_DIR=${HOME}/.cache/uv
21
 
22
- # Install dependencies from lockfile using cache/bind mounts
23
- RUN --mount=type=cache,target=${HOME}/.cache/uv \
24
- --mount=type=bind,source=uv.lock,target=uv.lock,readonly \
25
  --mount=type=bind,source=pyproject.toml,target=pyproject.toml,readonly \
26
  uv sync --locked --no-install-project --no-dev
27
 
28
  # Then, add the rest of the project source code and install it
29
  # Installing separately from its dependencies allows optimal layer caching
30
  COPY --chown=${USERNAME}:${USERNAME} . ${HOME}/app
31
- RUN --mount=type=cache,target=${HOME}/.cache/uv \
32
- uv sync --locked --no-dev
33
 
34
  # Place executables in the environment at the front of the path
35
  ENV PATH="${HOME}/app/.venv/bin:$PATH"
 
1
+ FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2
 
3
  ARG USERNAME=user
4
  ARG USER_UID=1000
 
19
  # Writable UV cache for non-root user
20
  ENV UV_CACHE_DIR=${HOME}/.cache/uv
21
 
22
+ # Install dependencies from lockfile using bind mounts (no cache mount to avoid perms issues)
23
+ RUN --mount=type=bind,source=uv.lock,target=uv.lock,readonly \
 
24
  --mount=type=bind,source=pyproject.toml,target=pyproject.toml,readonly \
25
  uv sync --locked --no-install-project --no-dev
26
 
27
  # Then, add the rest of the project source code and install it
28
  # Installing separately from its dependencies allows optimal layer caching
29
  COPY --chown=${USERNAME}:${USERNAME} . ${HOME}/app
30
+ RUN uv sync --locked --no-dev
 
31
 
32
  # Place executables in the environment at the front of the path
33
  ENV PATH="${HOME}/app/.venv/bin:$PATH"