feat(container): narrow build target scope to tracker image needs (closes #1853) - #1867
Conversation
There was a problem hiding this comment.
Pull request overview
This PR speeds up container image builds by narrowing the Rust build target scope in the Containerfile to only what’s needed for the tracker runtime image (while still retaining tests), and fixes a .dockerignore regression that could break local cold builds due to a missing workspace member manifest.
Changes:
- Remove
--benches --examples --all-targetsfromcargo chef cookandcargo nextest archivecommands in theContainerfile(debug + release, warmup + final archive). - Add a
.dockerignoreexception socontrib/dev-tools/analysis/workspace-coupling/Cargo.tomlis included in the Docker build context (required by the recipe stage manifest-onlyCOPY). - Update the issue spec doc for #1853 with completed tasks, verification evidence, and acceptance criteria status.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
Containerfile |
Narrows cargo build/archive target flags to reduce unnecessary compilation/linking during image build. |
.dockerignore |
Ensures a required workspace manifest is included so cargo chef prepare can succeed in local cold builds. |
docs/issues/open/1853-1840-workflow-performance-containerfile-target-scope/ISSUE.md |
Marks tasks/ACs as done and records verification evidence for the change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1867 +/- ##
========================================
Coverage 77.78% 77.78%
========================================
Files 382 382
Lines 28637 28637
Branches 28637 28637
========================================
+ Hits 22274 22275 +1
Misses 6054 6054
+ Partials 309 308 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
53e3647 to
ab23e4d
Compare
…oses torrust#1853) Remove `--benches --examples --all-targets` from all 6 cargo commands in the Containerfile (`cargo chef cook` × 2, warmup `cargo nextest archive` × 2, final `cargo nextest archive` × 2). Baseline analysis (torrust#1841) confirmed 27/30 top compile units are unrelated to the runtime image; benchmarks and examples alone account for ~250–300 s of avoidable link cost per profile. Cold no-cache release build succeeds in 5m23s with narrowed scope. Required executables (`torrust-tracker`, `http_health_check`) are present in the 173 MB release image. Also fixes a pre-existing `.dockerignore` bug: the audit in torrust#1851 excluded all of `contrib/dev-tools/` except `su-exec/`, but PR torrust#1863 (issue torrust#1852) later added a recipe-stage `COPY` for `contrib/dev-tools/analysis/workspace-coupling/Cargo.toml`. That path is a workspace member so `cargo chef prepare` requires its manifest. Add `!/contrib/dev-tools/analysis/workspace-coupling/Cargo.toml` to unblock local cold builds.
ab23e4d to
c33f1b8
Compare
|
ACK c33f1b8 |
Move closed issue specs from docs/issues/open/ to docs/issues/closed/: - #1841 - Baseline workflow profiling and bottleneck analysis (PR #1848) - #1853 - Narrow Containerfile build targets to tracker image needs (PR #1867) Update all references across EPIC, open specs, and draft specs to point to the new closed/ paths. Related to #1840
…losed specs #1841 and #1853 ea582a7 docs(issues): address Copilot review comments on #1868 spec (Jose Celano) a7e7320 chore(issues): archive closed issue specs #1841 and #1853 (Jose Celano) 5e12390 docs(issues): add issue specs for #1868 and #1869 (Jose Celano) Pull request description: ## Summary Spec-only PR — no code changes. All changes are in `docs/issues/`. ### New Issue Specs (opened and moved from `drafts/` to `open/`) - **#1868** — Exclude irrelevant workspace members from container build ([spec](docs/issues/open/1868-1840-workflow-performance-exclude-irrelevant-workspace-members/ISSUE.md)) — Post-merge CI analysis of PR #1867 showed `workspace-coupling` and `torrust-tracker-torrent-repository-benchmarking` are still compiled (~840s gap, 19m03s total build step). Fix: add `--exclude` flags to all 6 cargo commands. - **#1869** — Improve dependency-layer cache reuse within each workflow ([spec](docs/issues/open/1869-1840-workflow-performance-dependency-layer-cache-reuse/ISSUE.md)) — Investigate whether dependency cook layers are reliably reused when only app code changes. T3 also evaluates whether the cargo-chef cook/build split delivers meaningful benefit given workspace-package churn. ### Archived Closed Specs (`open/` → `closed/`) - **#1841** — Baseline workflow profiling (merged PR #1848) - **#1853** — Narrow Containerfile build targets (merged PR #1867) All cross-spec path references updated accordingly. ### EPIC Update EPIC #1840 subissues table updated: - Row 1: #1841 path → `closed/` - Row 4: #1853 marked DONE, path → `closed/` - Row 4.1: new row for #1868 - Row 7: promoted from draft placeholder to #1869 with `open/` path ## Related Related to #1840, #1853, #1868, #1869 ACKs for top commit: josecelano: ACK ea582a7 Tree-SHA512: d01814d19c3360fe08115077169d67795b7b6a2d33962cb115c76defa6fe3e0cf2879d10845cf2bf0ba64edf4b265c2206c1ddde05365e0d122d2b6264237a71
Summary
Removes
--benches --examples --all-targetsfrom all 6 cargo commands in the Containerfile (cargo chef cook× 2, warmupcargo nextest archive× 2, finalcargo nextest archive× 2).Baseline analysis (#1841) confirmed that 27/30 top compile units are unrelated to the runtime image, with benchmarks and examples alone accounting for ~250–300 s of avoidable link cost per profile.
Also fixes a pre-existing
.dockerignorebug introduced by #1851: that audit excluded all ofcontrib/dev-tools/exceptsu-exec/, but PR #1863 (issue #1852) later added a recipe-stageCOPYforcontrib/dev-tools/analysis/workspace-coupling/Cargo.toml. That path is a workspace member, socargo chef preparerequires its manifest. This bug caused local cold builds to fail silently (GHA layer-cache hits masked it in CI). Fix: add!/contrib/dev-tools/analysis/workspace-coupling/Cargo.tomlto.dockerignore.Changes
Containerfile: remove--benches --examples --all-targetsfrom:cargo chef cook(debug and release)cargo nextest archive(debug and release)cargo nextest archive(debug and release).dockerignore: add!/contrib/dev-tools/analysis/workspace-coupling/Cargo.tomlexceptiondocs/issues/open/1853-.../ISSUE.md: T1–T3 DONE, M1/M2 DONE with evidence, AC1/AC2 DONEVerification
linter all✅cargo test(all tests) ✅docker run --rm torrust-tracker:1853-test ls /usr/bin/torrust-tracker /usr/bin/http_health_check→ both present ✅Pending (CI)
Related
.dockerignoreregression from #1851 exposed by #1852