Use uv sync --locked in Dockerfile templates per official uv Docker guidance#279
Merged
Use uv sync --locked in Dockerfile templates per official uv Docker guidance#279
uv sync --locked in Dockerfile templates per official uv Docker guidance#279Conversation
…uidance Replace `uv pip install --system` with `uv sync --locked` in all 7 Dockerfile-uv.j2 templates. This uses the uv.lock file for reproducible builds, adds two-stage dependency installation for layer caching, BuildKit cache mounts, UV_COMPILE_BYTECODE for faster startup, and virtualenv PATH. Also remove uv.lock from existing .gitignore files that were blocking it.
danielmillerp
approved these changes
Mar 3, 2026
Contributor
Author
|
Tested with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To
Dockerfile-uv.j2templates:uv pip install --systemwithuv sync --lockedUV_COMPILE_BYTECODE=1.venvin pathThese changes are all based on:
https://docs.astral.sh/uv/guides/integration/docker/
Greptile Summary
Migrates all 7
Dockerfile-uv.j2templates fromuv pip install --systemtouv sync --locked, following the official uv Docker guidance. Also un-ignoresuv.lockfiles in.gitignoreso they can be committed (required by--locked).--no-install-project), then the project code is copied and installed separately. This maximizes Docker layer caching — code changes no longer invalidate the dependency layer.--mount=type=cache,target=/root/.cache/uvreuses the uv cache across builds, speeding up rebuilds.UV_COMPILE_BYTECODE=1: Pre-compiles.pycfiles at build time for faster container startup.UV_LINK_MODE=copy: Ensures files are copied into the venv rather than hardlinked, which is the correct behavior inside containers..venvinPATH: Replaces the previous--systeminstall approach with a proper virtual environment, adding it toPATHsopythonanduvicornresolve correctly..gitignoreupdates: Removesuv.lockfrom ignore patterns in both root andexamples/demos/procurement_agent/so lockfiles can be committed to version control.Confidence Score: 5/5
.gitignorechanges correctly allowuv.lockto be committed, which is required by--locked. No functional regressions introduced — the temporal templates retain their tctl installation and the pre-existingPYTHONPATHdifference is unchanged.Important Files Changed
uv pip install --systemtouv sync --lockedwith two-stage dependency install, cache mounts, bytecode compilation, and.venvin PATH. Correct and well-structured.uv sync --lockedpattern with proper layer caching.uv sync --lockedpattern with proper layer caching.uv sync --lockedpattern with proper layer caching.uv sync --lockedpattern with proper layer caching.uv sync --locked. Correctly retains tctl installation step. MissingPYTHONPATH=/appis a pre-existing difference from non-temporal templates.examples/**/uv.lockfrom gitignore sinceuv.lockfiles must be committed foruv sync --lockedto work.uv.lockfrom gitignore, consistent with the root.gitignorechange.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["FROM python:3.12-slim + uv"] --> B["apt-get install system deps"] B --> C["Set ENV: UV_COMPILE_BYTECODE=1, UV_LINK_MODE=copy"] C --> D["WORKDIR /app/project"] D --> E["COPY pyproject.toml + uv.lock"] E --> F["uv sync --locked --no-install-project --no-dev\n(cached: deps layer)"] F --> G["COPY project/ code"] G --> H["uv sync --locked --no-dev\n(install project into venv)"] H --> I["ENV PATH=.venv/bin:$PATH"] I --> J["CMD uvicorn project.acp:acp"] style E fill:#e1f5fe style F fill:#b3e5fc style G fill:#e1f5fe style H fill:#b3e5fc style I fill:#c8e6c9Last reviewed commit: 005dfec