-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
questionAsking for clarification or supportAsking for clarification or support
Description
The doc proposes the following Dockerfile to build a project into a Dockerfile while caching intermediate layers (uv version 0.4.0):
# Install uv
FROM python:3.12-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Change the working directory to the `app` directory
WORKDIR /app
# Copy the lockfile and `pyproject.toml` into the image
ADD uv.lock /app/uv.lock
ADD pyproject.toml /app/pyproject.toml
# Install dependencies
RUN uv sync --frozen --no-install-project
# Copy the project into the image
ADD . /app
# Sync the project
RUN uv sync --frozenHowever, when the project is a worskpace, uv sync --frozen --no-install-project won't do anything unless the workspace members are there. As a result, if a workspace contains libs in a libs/ dir, one has to also ADD all libs/*/pyproject.toml files so uv sync --frozen --no-install-project actually installs 3rd party dependencies.
We could easily COPY the whole libs/ dir, but then the cache would be invalidated every time sources change.
Is there a workaround? Or a workspace-specific strategy for building Docker images?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionAsking for clarification or supportAsking for clarification or support