From a7ab5ffa46756c5abba07c38a40894fa83081da4 Mon Sep 17 00:00:00 2001 From: Eetu Sutinen Date: Tue, 11 Aug 2026 22:57:19 +0300 Subject: [PATCH] Dockerfile: copy the shared backend crate into the image build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The image build has been broken since scene-backend landed; it only surfaced now because the workspace-deps layer was cached until something invalidated it. Two omissions. The cache-warm stage copied four manifests but not crates/scene-backend/Cargo.toml — and cargo parses the WHOLE workspace before building any of it, so a member whose manifest it cannot read is a hard error ("failed to load manifest for workspace member … failed to read crates/scene-backend/Cargo.toml"). And no stage copied that crate's real source, so once the manifest was there the backends would have compiled against an empty stub lib and failed on every item they use. The manifest and a stub lib join the warm stage; the real source lands in one shared-build stage that all three backend stages now extend, so a change to the shared crate rebuilds the three of them from the same layer. Verified the failing step locally without a container: reproducing the stage's exact copy set in a temp dir makes cargo emit that identical error, and adding the manifest makes it parse. --- Dockerfile | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8a5f768f..208325dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,12 +54,18 @@ COPY apps/tracker/backend/Cargo.toml apps/tracker/backend/Cargo.toml COPY apps/tracker/integration/Cargo.toml apps/tracker/integration/Cargo.toml COPY apps/party/backend/Cargo.toml apps/party/backend/Cargo.toml COPY services/transcoder/Cargo.toml services/transcoder/Cargo.toml +# EVERY workspace member's manifest has to be here, not just the ones being built: +# cargo parses the whole workspace before it builds any of it, and a path +# dependency it cannot read is a hard error ("failed to load manifest for +# workspace member"). scene-backend is both — a member and the crate all three +# backends depend on. +COPY crates/scene-backend/Cargo.toml crates/scene-backend/Cargo.toml # Stub sources so cargo can parse + warm the dep cache for every shipped crate. # integration is test-only (never built here) but its manifest must parse → stub lib. # tracker-backend declares extra bins (tracker-migrate, tracker-enrich — offline # tools); their src files must exist for cargo to resolve the manifest even though # only the server bin ships. -RUN mkdir -p apps/tracker/backend/src/bin apps/tracker/integration/src apps/party/backend/src services/transcoder/src \ +RUN mkdir -p apps/tracker/backend/src/bin apps/tracker/integration/src apps/party/backend/src services/transcoder/src crates/scene-backend/src \ && printf 'fn main() {}\n' > apps/tracker/backend/src/main.rs \ && : > apps/tracker/backend/src/lib.rs \ && printf 'fn main() {}\n' > apps/tracker/backend/src/bin/migrate.rs \ @@ -68,9 +74,20 @@ RUN mkdir -p apps/tracker/backend/src/bin apps/tracker/integration/src apps/part && printf 'fn main() {}\n' > apps/party/backend/src/main.rs \ && : > apps/party/backend/src/lib.rs \ && printf 'fn main() {}\n' > services/transcoder/src/main.rs \ + && : > crates/scene-backend/src/lib.rs \ && xx-cargo build --release -p tracker-backend -p party-backend -p scene-transcoder -FROM workspace-deps AS tracker-backend-build +# The shared crate's REAL source, in one stage the three backend stages extend. +# It has to land before any of them build: with only the stub lib in place they +# would compile against an empty scene-backend and fail on every item they use. +# Here rather than repeated per backend so a change to it rebuilds all three from +# the same layer. +FROM workspace-deps AS shared-build +ARG TARGETPLATFORM +COPY crates/scene-backend/src ./crates/scene-backend/src +RUN touch crates/scene-backend/src/lib.rs + +FROM shared-build AS tracker-backend-build ARG TARGETPLATFORM COPY apps/tracker/backend/src ./apps/tracker/backend/src # `touch` so cargo notices the stub→real source swap (shared target dir → only @@ -80,14 +97,14 @@ RUN touch apps/tracker/backend/src/main.rs apps/tracker/backend/src/lib.rs \ && xx-cargo build --release -p tracker-backend --bin tracker-backend \ && cp target/*/release/tracker-backend /tracker-backend -FROM workspace-deps AS party-backend-build +FROM shared-build AS party-backend-build ARG TARGETPLATFORM COPY apps/party/backend/src ./apps/party/backend/src RUN touch apps/party/backend/src/main.rs apps/party/backend/src/lib.rs \ && xx-cargo build --release -p party-backend \ && cp target/*/release/party-backend /party-backend -FROM workspace-deps AS transcoder-build +FROM shared-build AS transcoder-build ARG TARGETPLATFORM COPY services/transcoder/src ./services/transcoder/src RUN touch services/transcoder/src/main.rs \