[CI] Preserve Rust Docker cache across commits (#53290)
Signed-off-by: mgoin <mgoin64@gmail.com> Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
299ebd094a
commit
c9331d8064
+12
-10
@@ -253,7 +253,7 @@ ENV TORCH_CUDA_ARCH_LIST=${torch_cuda_arch_list}
|
||||
# build stage doesn't need the rust toolchain or the rust source.
|
||||
# This stage reuses the Python environment from base and runs in parallel with
|
||||
# csrc-build/extensions-build.
|
||||
FROM base AS rust-build
|
||||
FROM base AS rust-build-cache
|
||||
ARG USE_SCCACHE
|
||||
ARG SCCACHE_ENDPOINT
|
||||
|
||||
@@ -283,26 +283,28 @@ ENV CARGO_BUILD_JOBS=4
|
||||
# separate local sccache daemon while sharing the same remote cache backend.
|
||||
ENV SCCACHE_SERVER_PORT=4227
|
||||
|
||||
# Only Rust inputs are present, so suppress the artificial dirty state caused
|
||||
# by other tracked files being absent from this build stage.
|
||||
ENV SETUPTOOLS_SCM_PRETEND_METADATA={dirty=false}
|
||||
|
||||
# Build the release artifacts. Cache cargo registry/git, but not target/,
|
||||
# because stale target metadata can outlive source updates across BuildKit
|
||||
# cache reuse.
|
||||
# Build with a stable version so this target snapshot is keyed only by Rust
|
||||
# inputs. The child stage below relinks the crates that embed the exact version.
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
--mount=type=bind,source=.git,target=.git \
|
||||
--mount=type=secret,id=aws-credentials,target=/root/.aws/credentials,required=false \
|
||||
if [ "$USE_SCCACHE" = "1" ]; then \
|
||||
if [ -n "${SCCACHE_ENDPOINT}" ]; then export SCCACHE_ENDPOINT="${SCCACHE_ENDPOINT}"; fi; \
|
||||
export RUSTC_WRAPPER=sccache; \
|
||||
sccache --show-stats; \
|
||||
fi \
|
||||
&& bash build_rust.sh \
|
||||
&& SETUPTOOLS_SCM_PRETEND_VERSION="0.0.0+docker.cache" bash build_rust.sh \
|
||||
&& if [ "$USE_SCCACHE" = "1" ]; then \
|
||||
sccache --show-stats; \
|
||||
fi
|
||||
|
||||
# Relink with the exact Git-derived package version.
|
||||
FROM rust-build-cache AS rust-build
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
--mount=type=bind,source=.git,target=.git \
|
||||
SETUPTOOLS_SCM_PRETEND_METADATA="{dirty=false}" bash build_rust.sh
|
||||
#################### RUST BUILD IMAGE ####################
|
||||
|
||||
#################### CSRC BUILD IMAGE ####################
|
||||
|
||||
+12
-10
@@ -129,7 +129,7 @@ RUN echo 'ulimit -c 0' >> ~/.bashrc
|
||||
# Build the Rust frontend (`vllm-rs`) in a dedicated stage so the wheel build
|
||||
# stage doesn't need the rust toolchain. This stage runs in parallel
|
||||
# with the main vllm-build stage.
|
||||
FROM base AS rust-build
|
||||
FROM base AS rust-build-cache
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -y \
|
||||
@@ -163,25 +163,27 @@ COPY build_rust.sh build_rust.sh
|
||||
# (rustc spawns enough concurrent processes to hit RLIMIT_NOFILE otherwise).
|
||||
ENV CARGO_BUILD_JOBS=4
|
||||
|
||||
# Only Rust inputs are present, so suppress the artificial dirty state caused
|
||||
# by other tracked files being absent from this build stage.
|
||||
ENV SETUPTOOLS_SCM_PRETEND_METADATA={dirty=false}
|
||||
|
||||
# Build the release artifacts. Cache cargo registry/git, but not target/,
|
||||
# because stale target metadata can outlive source updates across BuildKit
|
||||
# cache reuse.
|
||||
# Build with a stable version so this target snapshot is keyed only by Rust
|
||||
# inputs. The child stage below relinks the crates that embed the exact version.
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
--mount=type=bind,source=.git,target=.git \
|
||||
--mount=type=secret,id=aws-credentials,target=/root/.aws/credentials,required=false \
|
||||
if [ "$USE_SCCACHE" = "1" ]; then \
|
||||
export RUSTC_WRAPPER=sccache; \
|
||||
if [ -n "${SCCACHE_ENDPOINT}" ]; then export SCCACHE_ENDPOINT="${SCCACHE_ENDPOINT}"; fi; \
|
||||
sccache --show-stats; \
|
||||
fi && \
|
||||
bash build_rust.sh && \
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION="0.0.0+docker.cache" bash build_rust.sh && \
|
||||
if [ "$USE_SCCACHE" = "1" ]; then sccache --show-stats; fi
|
||||
|
||||
# Relink with the exact Git-derived package version.
|
||||
FROM rust-build-cache AS rust-build
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
--mount=type=bind,source=.git,target=.git \
|
||||
SETUPTOOLS_SCM_PRETEND_METADATA="{dirty=false}" bash build_rust.sh
|
||||
|
||||
######################### SOURCE PREP IMAGE #########################
|
||||
# Shared prep (source, rust artifacts, build deps) for both vllm-build and
|
||||
# vllm-dev, so the two independent compiles (bdist_wheel vs. setup.py
|
||||
|
||||
+10
-5
@@ -1,7 +1,7 @@
|
||||
######################### RUST BUILD IMAGE #########################
|
||||
# Build the Rust frontend (`vllm-rs`) in a dedicated stage so the main image
|
||||
# doesn't need the rust toolchain. Runs in parallel with vllm-base.
|
||||
FROM ubuntu:22.04 AS rust-build
|
||||
FROM ubuntu:22.04 AS rust-build-cache
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -y \
|
||||
@@ -25,14 +25,19 @@ COPY build_rust.sh build_rust.sh
|
||||
# (rustc spawns enough concurrent processes to hit RLIMIT_NOFILE otherwise).
|
||||
ENV CARGO_BUILD_JOBS=4
|
||||
|
||||
# Only Rust inputs are present, so suppress the artificial dirty state caused
|
||||
# by other tracked files being absent from this build stage.
|
||||
ENV SETUPTOOLS_SCM_PRETEND_METADATA={dirty=false}
|
||||
# Build with a stable version so this target snapshot is keyed only by Rust
|
||||
# inputs. The child stage below relinks the crates that embed the exact version.
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
SETUPTOOLS_SCM_PRETEND_VERSION="0.0.0+docker.cache" bash build_rust.sh
|
||||
|
||||
# Relink with the exact Git-derived package version.
|
||||
FROM rust-build-cache AS rust-build
|
||||
|
||||
RUN --mount=type=cache,target=/root/.cargo/registry,sharing=locked \
|
||||
--mount=type=cache,target=/root/.cargo/git,sharing=locked \
|
||||
--mount=type=bind,source=.git,target=.git \
|
||||
bash build_rust.sh
|
||||
SETUPTOOLS_SCM_PRETEND_METADATA="{dirty=false}" bash build_rust.sh
|
||||
|
||||
FROM ubuntu:24.04 AS vllm-base
|
||||
|
||||
|
||||
Reference in New Issue
Block a user