perf(docker): reuse dependency layers and preserve build caches
This commit is contained in:
1 parent
31691c1c7d
commit
2840ef5d9d
4 files changed
+59
-34
No files matched your search
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user