mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-02 00:25:34 +08:00
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:
@@ -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/
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user