From 693e73e341534d45b4e434007ee77fea7105508d Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 20 Nov 2025 08:43:54 -0600 Subject: [PATCH] Add documentation for intermediate layers with a workspace --- docs/guides/integration/docker.md | 38 ++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/docs/guides/integration/docker.md b/docs/guides/integration/docker.md index 71668e5c44d2f..ac5324b8e2ed6 100644 --- a/docs/guides/integration/docker.md +++ b/docs/guides/integration/docker.md @@ -424,10 +424,42 @@ _contents_ are not copied into the image until the final `uv sync` command. !!! tip - If you're using a [workspace](../../concepts/projects/workspaces.md), then use the - `--no-install-workspace` flag which excludes the project _and_ any workspace members. + If you want to remove additional, specific packages from the sync, + use `--no-install-package `. - If you want to remove specific packages from the sync, use `--no-install-package `. +#### Intermediate layers in workspaces + +If you're using a [workspace](../../concepts/projects/workspaces.md), then a couple changes are +needed: + +- Copy all of the workspace member `pyproject.toml` files +- Use the `--no-install-workspace` flag which excludes the project _and_ any workspace members. + +```dockerfile title="Dockerfile" +# Install uv +FROM python:3.12-slim +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +WORKDIR /app + +RUN --mount=type=cache,target=/root/.cache/uv \ + --mount=type=bind,source=uv.lock,target=uv.lock \ + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ + --mount=type=bind,source=foo/pyproject.toml,target=foo/pyproject.toml \ + --mount=type=bind,source=bar/pyproject.toml,target=bar/pyproject.toml \ + uv sync --locked --no-install-workspace + +ADD . /app + +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --locked +``` + +!!! tip + + Copying the workspace member `pyproject.toml` files is needed for `--locked` to assert that + the lockfile matches the contents of the `pyproject.toml`. The member `pyproject.toml` files can + be skipped by using `--frozen` during the workspace sync instead. ### Non-editable installs