




















@@ -143,14 +143,29 @@ describe("Dockerfile", () => {
143143});
144144145145it("keeps package manager patch files in runtime images", async () => {
146-const dockerfile = await readFile(dockerfilePath, "utf8");
146+const dockerfile = collapseDockerContinuations(await readFile(dockerfilePath, "utf8"));
147147const pnpmWorkspace = YAML.parse(await readFile(pnpmWorkspacePath, "utf8")) as {
148148patchedDependencies?: Record<string, string>;
149149};
150+const saveSourceWorkspace = "cp pnpm-workspace.yaml /tmp/pnpm-workspace.source.yaml";
151+const usePruneWorkspace = "cp /tmp/pnpm-workspace.runtime.yaml pnpm-workspace.yaml";
152+const pruneProd = "CI=true NPM_CONFIG_FROZEN_LOCKFILE=false pnpm prune --prod";
153+const restoreSourceWorkspace = "cp /tmp/pnpm-workspace.source.yaml pnpm-workspace.yaml";
154+const finalWorkspaceCopy =
155+"COPY --from=runtime-assets --chown=node:node /app/pnpm-workspace.yaml .";
150156151157expect(Object.keys(pnpmWorkspace.patchedDependencies ?? {})).not.toHaveLength(0);
152-expect(dockerfile).toContain(
153-"COPY --from=runtime-assets --chown=node:node /app/pnpm-workspace.yaml .",
158+expect(dockerfile).toContain(saveSourceWorkspace);
159+expect(dockerfile).toContain(usePruneWorkspace);
160+expect(dockerfile).toContain(restoreSourceWorkspace);
161+expect(dockerfile).toContain(finalWorkspaceCopy);
162+expect(dockerfile.indexOf(saveSourceWorkspace)).toBeLessThan(
163+dockerfile.indexOf(usePruneWorkspace),
164+);
165+expect(dockerfile.indexOf(usePruneWorkspace)).toBeLessThan(dockerfile.indexOf(pruneProd));
166+expect(dockerfile.indexOf(pruneProd)).toBeLessThan(dockerfile.indexOf(restoreSourceWorkspace));
167+expect(dockerfile.indexOf(restoreSourceWorkspace)).toBeLessThan(
168+dockerfile.indexOf(finalWorkspaceCopy),
154169);
155170expect(dockerfile).toContain(
156171"COPY --from=runtime-assets --chown=node:node /app/patches ./patches",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。