perf(docker): reuse dependency layers and preserve build caches
CI / check (push) Successful in 1m31s
CI / deploy (push) Successful in 1m42s
CI / e2e (push) Successful in 26s

This commit is contained in:
Simo committed 2026-09-06 11:01:31 +02:00
1 parent 31691c1c7d
commit 2840ef5d9d
4 files changed
+59 -34

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const dockerfile = readFileSync("Dockerfile", "utf8");
describe("Docker build cache", () => {
it("installs frozen dependencies before copying application source", () => {
const manifests = dockerfile.indexOf(
"COPY package.json *lock* pnpm-workspace.yaml .npmrc ./",
);
const install = dockerfile.indexOf("pnpm install --frozen-lockfile");
const source = dockerfile.indexOf("COPY . .");
expect(manifests).toBeGreaterThan(-1);
expect(install).toBeGreaterThan(manifests);
expect(source).toBeGreaterThan(install);
});
it("retains the package store and Next compiler cache across source changes", () => {
expect(dockerfile).toContain("id=epicnext-pnpm,target=/pnpm/store");
expect(dockerfile).toContain("--store-dir=/pnpm/store");
expect(dockerfile).toContain("id=epicnext-next,target=/app/.next/cache");
});
it("ships standalone output without a redundant dependency pruning step", () => {
expect(dockerfile).toContain("/app/.next/standalone ./");
expect(dockerfile).not.toContain("pnpm prune --prod");
expect(dockerfile).not.toContain("npm prune --production");
expect(dockerfile).not.toContain("yarn install --production");
});
});