perf(build): keep test suites out of the image and cache CI builds durably
CI / check (push) Successful in 30s
CI / tests-unit (push) Successful in 1m53s
CI / tests-integration (push) Successful in 1m54s
CI / tests-imaging-browsers (push) Successful in 2m26s
CI / tests-quality (push) Successful in 2m19s
CI / tests-ui (push) Successful in 4m31s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 3m9s
CI / check (push) Successful in 30s
CI / tests-unit (push) Successful in 1m53s
CI / tests-integration (push) Successful in 1m54s
CI / tests-imaging-browsers (push) Successful in 2m26s
CI / tests-quality (push) Successful in 2m19s
CI / tests-ui (push) Successful in 4m31s
CI / preflight (push) Skipped
CI / deploy (push) Failing after 3m9s
Three build-time improvements, all measured on this host. The build context no longer ships the test suites. `next build` type-checks the whole project, so `e2e/` and `integration/` in the context made the image build fail on a type error in test code and pulled @playwright/test, vitest, msw, testcontainers and drizzle-kit into the image. The CI runs those suites on the host. Type-check time in the build drops from 2.2s to 1.3s, and a contract test now fails if application code ever imports from those folders. The CI now exports the build cache to a directory outside the runner workspace: /var/cache/epicnext-cms-buildcache for the release and a separate map for branch preflights, so a branch can never feed the release cache. The workspace is wiped after every job and `docker builder prune` runs after every release, so the next build started with an empty cache and downloaded all 493 packages again (measured: reused 0, downloaded 493). With the durable export the frozen dependency layer is reused (measured: reused 493, downloaded 0) even after a full prune. A cache directory that is not writable only produces a warning; the release is never blocked. Investigated the remaining ~30s of Next.js build tracing: excluding the dev-only packages with `outputFileTracingExcludes` made it slower (35s vs 30s), because the traced output was already minimal (5 packages). The cost is Next's own page-config collection and file tracing over 329 routes, not the dependency set, so no configuration was kept.
This commit is contained in:
1 parent
8ca538f99f
commit
ecd8e5852c
8 files changed
+148
-2
No files matched your search
@@ -329,6 +329,24 @@ Two caches make repeated builds cheap:
|
||||
daemon cache to 4 GB after every deploy. The directory is ignored by both
|
||||
Git and the build context; delete it to force a cold build.
|
||||
|
||||
The CI has the same problem on a bigger scale: the runner workspace is wiped
|
||||
after every job and `scripts/docker-prune.sh` trims the daemon cache after
|
||||
every release, so the next build started with an empty cache and downloaded all
|
||||
493 packages again (measured: `reused 0, downloaded 493`). `scripts/ci-deploy.sh`
|
||||
and `scripts/ci-preflight.sh` therefore export the build cache to a directory
|
||||
outside the workspace — `/var/cache/epicnext-cms-buildcache` for the release and
|
||||
`/var/cache/epicnext-cms-preflight-cache` for branch preflights, so a branch can
|
||||
never feed the release cache. With that export in place the same build re-uses
|
||||
the frozen dependency layer (`reused 493, downloaded 0`) even after a full
|
||||
`docker builder prune`. Set `CMS_BUILD_CACHE_DIR` to another path to move the
|
||||
cache, or to an empty value to switch it off.
|
||||
|
||||
The build context excludes `e2e/` and `integration/`. `next build` type-checks
|
||||
the whole project, so shipping the test suites inside the image made a type
|
||||
error in test code break the image build and pulled `@playwright/test`, `vitest`,
|
||||
`msw` and `testcontainers` into it. The CI runs those suites on the host
|
||||
(`pnpm test:ui`, `pnpm test:integration`).
|
||||
|
||||
### Volumes
|
||||
|
||||
Only the CMS (and the optional avatar imager container, see [Avatar Imaging](#avatar-imaging)) run in Docker. The heavy client assets and gamedata stay on the host and are shared into the container so imports and uploads persist:
|
||||
|
||||
Reference in new issue
Block a user