wip: paused before review (#7890)

This commit is contained in:
Michael Wang
2026-11-16 01:24:13 +00:00
committed by GitHub
parent 1e542956d9
commit 5d8605eb8e
4 changed files with 53 additions and 0 deletions
+8
View File
@@ -1938,6 +1938,14 @@ Low-memory detection reads **host** RAM, not cgroup or container limits, so
containerised callers — including `--docker` — should set
`PRODUCER_LOW_MEMORY_MODE` explicitly.
`--docker` runs the render container on Docker's default network, which can
reach your machine, your local network and the internet. It does not restrict
what the rendered page loads unless you ask it to. When you set
`PRODUCER_RESTRICT_PAGE_NETWORK` or `PRODUCER_NON_PUBLIC_CIDRS` in the shell
that runs `hyperframes render --docker`, the CLI passes them into the container,
so the render there refuses the same addresses a local render would. See
[the producer docs](/packages/producer) for what the restriction allows.
Render Chrome keeps its sandbox on macOS, on Windows, and on Linux for a
non-root user outside a container. It runs without one as root, in Docker,
Podman or Kubernetes, on AWS Lambda and Cloud Run, and where Linux restricts
+4
View File
@@ -232,6 +232,10 @@ add it with `PRODUCER_NON_PUBLIC_CIDRS`, a comma-separated list like `192.160.0.
downloads and the render browser then refuse those addresses too. A malformed entry
refuses every address rather than being skipped, and logs a warning.
`hyperframes render --docker` passes both settings into its render container when they
are set in the shell that runs it. When they are not set, the container's render page can
reach anything the container's network can, including private addresses.
## Related topics
<CardGroup cols={2}>
@@ -26,6 +26,7 @@ const FIXED_INPUT = {
// flip between linux/amd64 and linux/arm64 depending on the host running
// the test).
platform: "linux/amd64",
hostEnv: {},
};
describe("buildDockerRunArgs", () => {
@@ -68,6 +69,30 @@ describe("buildDockerRunArgs", () => {
`);
});
it("forwards the host's render-network restriction into the container only when it is set", () => {
const envArgs = (hostEnv: Record<string, string | undefined>) => {
const args = buildDockerRunArgs({ ...FIXED_INPUT, hostEnv, options: BASE });
const beforeImage = args.slice(0, args.indexOf(FIXED_INPUT.imageTag));
return beforeImage.filter((_, i) => beforeImage[i - 1] === "-e");
};
expect(
envArgs({
PRODUCER_RESTRICT_PAGE_NETWORK: "Yes",
PRODUCER_NON_PUBLIC_CIDRS: "192.160.0.0/16,fd00::/8",
}),
).toEqual([
"PRODUCER_RESTRICT_PAGE_NETWORK=Yes",
"PRODUCER_NON_PUBLIC_CIDRS=192.160.0.0/16,fd00::/8",
]);
expect(envArgs({ PRODUCER_RESTRICT_PAGE_NETWORK: "maybe" })).toEqual([
"PRODUCER_RESTRICT_PAGE_NETWORK=maybe",
]);
expect(envArgs({})).toEqual([]);
expect(envArgs({ PRODUCER_RESTRICT_PAGE_NETWORK: " ", PRODUCER_NON_PUBLIC_CIDRS: "" })).toEqual(
[],
);
});
it("tells the container its output reaches a terminal only when the host's stdout is one", () => {
const flags = (hostStdoutIsTty?: boolean) =>
buildDockerRunArgs({ ...FIXED_INPUT, hostStdoutIsTty, options: BASE }).slice(0, 4);
+16
View File
@@ -28,6 +28,8 @@ export interface DockerRunArgsInput {
* byte-for-byte parity with amd64 renders.
*/
platform?: string;
/** Environment read for the render-network settings forwarded into the container. Defaults to `process.env`. */
hostEnv?: Readonly<Record<string, string | undefined>>;
options: DockerRenderOptions;
}
@@ -106,6 +108,19 @@ export function resolveDockerPlatform(
return arch === "arm64" ? "linux/arm64" : "linux/amd64";
}
/** Settings the in-container engine reads to restrict the render page's network, passed through as set on the host. */
const FORWARDED_RENDER_NETWORK_ENV = [
"PRODUCER_RESTRICT_PAGE_NETWORK",
"PRODUCER_NON_PUBLIC_CIDRS",
];
function renderNetworkEnvArgs(env: Readonly<Record<string, string | undefined>>): string[] {
return FORWARDED_RENDER_NETWORK_ENV.flatMap((name) => {
const value = env[name];
return value?.trim() ? ["-e", `${name}=${value}`] : [];
});
}
// Pure argv builder — the cognitive count tracks the number of optional CLI
// flags it forwards, not branching depth. Each conditional spread is one
// option = O(1) to read. Inherited from main (#1196 added platform handling);
@@ -118,6 +133,7 @@ export function buildDockerRunArgs(input: DockerRunArgsInput): string[] {
"run",
"--rm",
...(input.hostStdoutIsTty ? ["-e", "HYPERFRAMES_STDOUT_IS_TTY=1"] : []),
...renderNetworkEnvArgs(input.hostEnv ?? process.env),
"--platform",
platform,
"--shm-size=2g",