From 09572babee79226f8d3a2a9debb5ac47bafdcf89 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Wed, 29 Jul 2026 15:04:46 +0200 Subject: [PATCH] perf(docker): split dependency install from source copy for CI layer caching (#4208) * perf(docker): split dep install from src copy for CI layer caching Install third-party deps (torch + all extras) in a layer keyed only on pyproject.toml + uv.lock via --no-install-project, then copy src and install the local package. Editing src/ no longer busts the heavy dependency layer, so BuildKit layer cache hits across CI builds. Applied to both Dockerfile.user and Dockerfile.internal. * chore(ci): less verbose comments + copy all files --------- Co-authored-by: dongmao.zhang --- docker/Dockerfile.internal | 9 ++++----- docker/Dockerfile.user | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docker/Dockerfile.internal b/docker/Dockerfile.internal index 19f0167b3..c1c54dba9 100644 --- a/docker/Dockerfile.internal +++ b/docker/Dockerfile.internal @@ -68,17 +68,16 @@ ENV HOME=/home/user_lerobot \ # issues with MuJoCo and OpenGL drivers. RUN uv venv --python python${PYTHON_VERSION} -# Install Python dependencies for caching +# Install third-party dependencies separately for layer caching COPY --chown=user_lerobot:user_lerobot setup.py pyproject.toml uv.lock README.md MANIFEST.in ./ -COPY --chown=user_lerobot:user_lerobot src/ src/ - -RUN uv sync --locked --extra all --no-cache +RUN uv sync --locked --extra all --no-install-project --no-cache RUN chmod +x /lerobot/.venv/lib/python${PYTHON_VERSION}/site-packages/triton/backends/nvidia/bin/ptxas -# Copy the rest of the application source code +# Copy the application source code and install the local project # Make sure to have the git-LFS files for testing COPY --chown=user_lerobot:user_lerobot . . +RUN uv sync --locked --extra all --no-cache # Set the default command CMD ["/bin/bash"] diff --git a/docker/Dockerfile.user b/docker/Dockerfile.user index 2aae8b321..8d6bf5005 100644 --- a/docker/Dockerfile.user +++ b/docker/Dockerfile.user @@ -60,15 +60,14 @@ ENV HOME=/home/user_lerobot \ # run other Python projects in the same container without dependency conflicts. RUN uv venv -# Install Python dependencies for caching +# Install third-party dependencies separately for layer caching COPY --chown=user_lerobot:user_lerobot setup.py pyproject.toml uv.lock README.md MANIFEST.in ./ -COPY --chown=user_lerobot:user_lerobot src/ src/ +RUN uv sync --locked --extra all --no-install-project --no-cache -RUN uv sync --locked --extra all --no-cache - -# Copy the rest of the application code +# Copy the application code and install the local project # Make sure to have the git-LFS files for testing COPY --chown=user_lerobot:user_lerobot . . +RUN uv sync --locked --extra all --no-cache # Set the default command CMD ["/bin/bash"]