Skip to content

feat(container): narrow build target scope to tracker image needs (closes #1853) - #1867

Merged
josecelano merged 1 commit into
torrust:developfrom
josecelano:1853-containerfile-target-scope
Jun 2, 2026
Merged

feat(container): narrow build target scope to tracker image needs (closes #1853)#1867
josecelano merged 1 commit into
torrust:developfrom
josecelano:1853-containerfile-target-scope

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

Removes --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 (#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 .dockerignore bug introduced by #1851: that audit excluded all of contrib/dev-tools/ except su-exec/, but PR #1863 (issue #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. 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.toml to .dockerignore.

Changes

  • Containerfile: remove --benches --examples --all-targets from:
    • cargo chef cook (debug and release)
    • warmup cargo nextest archive (debug and release)
    • final cargo nextest archive (debug and release)
  • .dockerignore: add !/contrib/dev-tools/analysis/workspace-coupling/Cargo.toml exception
  • docs/issues/open/1853-.../ISSUE.md: T1–T3 DONE, M1/M2 DONE with evidence, AC1/AC2 DONE

Verification

  • linter all
  • cargo test (all tests) ✅
  • Pre-push checks (nightly fmt, check, doc, stable tests) ✅
  • Cold no-cache release build: 5m23s
  • docker run --rm torrust-tracker:1853-test ls /usr/bin/torrust-tracker /usr/bin/http_health_check → both present ✅
  • Release image size: 173 MB

Pending (CI)

  • AC3: container workflow timing improvement (CI will show before/after)
  • AC4: Docker E2E compatibility (CI testing.yaml)

Related

  • Part of EPIC #1840 — Improve PR Workflow Performance
  • Depends on baseline #1841
  • Fixes .dockerignore regression from #1851 exposed by #1852

@josecelano josecelano self-assigned this Jun 2, 2026
@josecelano
josecelano marked this pull request as ready for review June 2, 2026 11:58
Copilot AI review requested due to automatic review settings June 2, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-targets from cargo chef cook and cargo nextest archive commands in the Containerfile (debug + release, warmup + final archive).
  • Add a .dockerignore exception so contrib/dev-tools/analysis/workspace-coupling/Cargo.toml is included in the Docker build context (required by the recipe stage manifest-only COPY).
  • 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.

Comment thread Containerfile Outdated
Comment thread Containerfile Outdated
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.78%. Comparing base (455257c) to head (c33f1b8).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@josecelano
josecelano force-pushed the 1853-containerfile-target-scope branch from 53e3647 to ab23e4d Compare June 2, 2026 12:22
…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.
@josecelano
josecelano force-pushed the 1853-containerfile-target-scope branch from ab23e4d to c33f1b8 Compare June 2, 2026 14:46
@josecelano

Copy link
Copy Markdown
Member Author

ACK c33f1b8

@josecelano
josecelano merged commit f9cd56c into torrust:develop Jun 2, 2026
18 checks passed
@josecelano josecelano linked an issue Jun 2, 2026 that may be closed by this pull request
4 tasks
josecelano added a commit that referenced this pull request Jun 3, 2026
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
josecelano added a commit that referenced this pull request Jun 3, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Narrow Containerfile build targets to tracker image needs

2 participants