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