Files
EpicNext-Cms/src/lib/docker-build-contract.test.ts
T
Simo 2840ef5d9d
CI / check (push) Successful in 1m31s
CI / deploy (push) Successful in 1m42s
CI / e2e (push) Successful in 26s
perf(docker): reuse dependency layers and preserve build caches
2026-09-06 11:01:31 +02:00

29 lines
1.2 KiB
TypeScript

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");
});
});