fix(sandbox): include CLI lifecycle scripts

- Copy the CLI cache-warming postinstall script before the Docker dependency install layer
- Include the script in the restricted Docker build context
- Add regression coverage for lifecycle-script ordering and context availability
This commit is contained in:
Chris Tate
2026-08-26 21:51:15 -05:00
parent 77fad3c4cc
commit f71922fcb0
3 changed files with 26 additions and 0 deletions
+2
View File
@@ -5,6 +5,8 @@
!packages/
!packages/cli/
!packages/cli/package.json
!packages/cli/scripts/
!packages/cli/scripts/warm-cache.mjs
!packages/compiler/
!packages/compiler/package.json
!packages/runtime/
+1
View File
@@ -39,6 +39,7 @@ WORKDIR /workspace
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY packages/cli/package.json packages/cli/package.json
COPY packages/cli/scripts/warm-cache.mjs packages/cli/scripts/warm-cache.mjs
COPY packages/compiler/package.json packages/compiler/package.json
COPY packages/runtime/package.json packages/runtime/package.json
+23
View File
@@ -0,0 +1,23 @@
import { readFileSync } from "node:fs";
import { describe, expect, test } from "vitest";
const dockerfile = readFileSync(new URL("../../Dockerfile.sandbox", import.meta.url), "utf8");
const dockerignore = readFileSync(new URL("../../.dockerignore", import.meta.url), "utf8");
describe("Sandbox Dockerfile", () => {
test("copies CLI lifecycle scripts before installing workspace dependencies", () => {
const packageIndex = dockerfile.indexOf(
"COPY packages/cli/package.json packages/cli/package.json",
);
const scriptIndex = dockerfile.indexOf(
"COPY packages/cli/scripts/warm-cache.mjs packages/cli/scripts/warm-cache.mjs",
);
const installIndex = dockerfile.indexOf("RUN pnpm install --frozen-lockfile");
expect(packageIndex).toBeGreaterThanOrEqual(0);
expect(scriptIndex).toBeGreaterThan(packageIndex);
expect(installIndex).toBeGreaterThan(scriptIndex);
expect(dockerignore).toContain("!packages/cli/scripts/");
expect(dockerignore).toContain("!packages/cli/scripts/warm-cache.mjs");
});
});