diff --git a/Dockerfile b/Dockerfile index 8a5f768..208325d 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 \