Server image: keep dependencies fetched from GitHub between builds

agent-desktop comes from GitHub, and only the crates registry and target were cached, so every
server update fetched it again; a slow GitHub made nobledesktop's update fail (cargo exit 101, then
a fetch that hung for over ten minutes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Uirha2RVfSYmrhqNnqx9Z4
This commit is contained in:
王性驊 2026-11-06 18:15:22 +08:00
parent cab8177cf4
commit a202a96c02
1 changed files with 3 additions and 1 deletions

View File

@ -9,8 +9,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends pkg-config liba
ARG JOBS= ARG JOBS=
WORKDIR /src WORKDIR /src
COPY . . COPY . .
# The registry and target caches survive rebuilds, so an update only recompiles what changed. # The registry, git and target caches survive rebuilds, so an update only recompiles what changed
# (and a dependency taken from GitHub isn't fetched again: a slow GitHub failed a server's update).
RUN --mount=type=cache,target=/usr/local/cargo/registry \ RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
--mount=type=cache,target=/src/target \ --mount=type=cache,target=/src/target \
cargo build --release --bin anybot ${JOBS:+-j $JOBS} \ cargo build --release --bin anybot ${JOBS:+-j $JOBS} \
&& cp target/release/anybot /anybot && cp target/release/anybot /anybot