Skip to content

Commit 11745dc

Browse files
committed
fix(docker): ship declared example/bench sources in build context
The Railway/Docker build aborted at manifest parse: error: failed to parse manifest at `/app/Cargo.toml` Caused by: can't find `amx_gemm_bench` example at `examples/amx_gemm_bench.rs` ... Root cause: `.dockerignore` excluded `examples/` and `benches/` from the build context, but Cargo.toml declares explicit [[example]]/[[bench]] targets. Cargo validates that every explicitly-declared target's source file exists while *parsing* the manifest — even for a lib-only build — so `cargo build` aborts before compiling anything when those files are absent. `amx_gemm_bench` was just the first missing target reported; all 18 examples and 13 root benches were stripped, and the ndarray-rand workspace member's [[bench]] "bench" was also missing (its benches/ dir was never copied — only Cargo.toml + src/). Fix: - .dockerignore: stop excluding examples/ and benches/ so they are present in the build context (kept an NB comment explaining why). - Dockerfile + Dockerfile.avx512: COPY examples/, benches/, and ndarray-rand/benches/ before the build. These are NOT compiled by the default `cargo build` (examples/benches require --examples/--benches), so this adds only source bytes, not build time. Verified by staging the exact Docker COPY set locally: without the dirs, `cargo build` reproduces the parse error; with them, parse succeeds and the build advances past target validation into dependency/lib compilation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Kq2xzjPj9p2eoP64uy3Btg
1 parent f22a28b commit 11745dc

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

.dockerignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ target/
44
*.md
55
!README*.md
66
.github/
7-
benches/
8-
examples/
97
scripts/
8+
# NB: benches/ and examples/ are intentionally NOT ignored. Cargo.toml declares
9+
# explicit [[bench]] and [[example]] targets, and cargo validates that every
10+
# declared target's source file exists when it parses the manifest — even for a
11+
# lib-only build. Excluding these dirs makes `cargo build` fail at manifest
12+
# parse with "can't find <name> example/bench". They are not compiled by the
13+
# default build, so the cost of shipping them in the context is just their size.

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ COPY crates/ crates/
3434
COPY src/ src/
3535
COPY ndarray-rand/src/ ndarray-rand/src/
3636

37+
# Cargo.toml (root) and ndarray-rand/Cargo.toml (a workspace member) declare
38+
# explicit [[example]]/[[bench]] targets. Cargo validates that every declared
39+
# target's source file exists while parsing the manifest — even for a lib-only
40+
# build — so these dirs must be in the context or `cargo build` fails at parse
41+
# with "can't find <name> example/bench". They are NOT compiled here (the default
42+
# build skips examples/benches), so this only adds source bytes, not build time.
43+
COPY examples/ examples/
44+
COPY benches/ benches/
45+
COPY ndarray-rand/benches/ ndarray-rand/benches/
46+
3747
# Default target: x86-64-v3 (AVX2) — runs on GitHub CI and most servers.
3848
# Use Dockerfile.avx512 for x86-64-v4 (AVX-512). ndarray's simd.rs polyfill
3949
# detects AVX-512 at runtime via LazyLock<Tier> even when compiled for v3;

Dockerfile.avx512

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ COPY crates/ crates/
3232
COPY src/ src/
3333
COPY ndarray-rand/src/ ndarray-rand/src/
3434

35+
# Cargo.toml (root) and ndarray-rand/Cargo.toml (a workspace member) declare
36+
# explicit [[example]]/[[bench]] targets. Cargo validates that every declared
37+
# target's source file exists while parsing the manifest — even for a lib-only
38+
# build — so these dirs must be in the context or `cargo build` fails at parse
39+
# with "can't find <name> example/bench". They are NOT compiled here (the default
40+
# build skips examples/benches), so this only adds source bytes, not build time.
41+
COPY examples/ examples/
42+
COPY benches/ benches/
43+
COPY ndarray-rand/benches/ ndarray-rand/benches/
44+
3545
# AVX-512 pinned: compile-time dispatch, everything inlined
3646
ENV RUSTFLAGS="-C target-cpu=x86-64-v4"
3747

0 commit comments

Comments
 (0)