Skip to content

Commit 4ef872f

Browse files
authored
containers: Do not force pull a specific proxy-everything image (#14358)
1 parent fab565f commit 4ef872f

4 files changed

Lines changed: 87 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"wrangler": patch
3+
"@cloudflare/vite-plugin": patch
4+
---
5+
6+
Fix container egress interception on arm64 Docker runtimes
7+
8+
Both `wrangler dev` and the Cloudflare Vite plugin no longer force the `proxy-everything` sidecar image to pull as `linux/amd64`, allowing Docker to select the native image from the multi-platform manifest. Set `MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM` to force a specific platform when needed.

packages/containers-shared/src/images.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import type {
2020
export const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE =
2121
"cloudflare/proxy-everything:3cb1195@sha256:0ef6716c52430096900b150d84a3302057d6cd2319dae7987128c85d0733e3c8";
2222

23+
export function getEgressInterceptorPlatform(): string | undefined {
24+
return process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM;
25+
}
26+
2327
export function getEgressInterceptorImage(): string {
2428
return (
2529
process.env.MINIFLARE_CONTAINER_EGRESS_IMAGE ??
@@ -31,7 +35,12 @@ export async function pullEgressInterceptorImage(
3135
dockerPath: string
3236
): Promise<void> {
3337
const image = getEgressInterceptorImage();
34-
await runDockerCmd(dockerPath, ["pull", image, "--platform", "linux/amd64"]);
38+
const platform = getEgressInterceptorPlatform();
39+
const args = ["pull", image];
40+
if (platform !== undefined) {
41+
args.push("--platform", platform);
42+
}
43+
await runDockerCmd(dockerPath, args);
3544
}
3645

3746
export async function pullImage(
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { beforeEach, describe, it, vi } from "vitest";
2+
import {
3+
getEgressInterceptorPlatform,
4+
pullEgressInterceptorImage,
5+
} from "../src/images";
6+
import { runDockerCmd } from "../src/utils";
7+
8+
vi.mock("../src/utils", () => ({
9+
runDockerCmd: vi.fn(() => ({
10+
abort: vi.fn(),
11+
ready: Promise.resolve({ aborted: false }),
12+
then: (resolve: () => void) => {
13+
resolve();
14+
},
15+
})),
16+
}));
17+
18+
describe("getEgressInterceptorPlatform", () => {
19+
beforeEach(() => {
20+
vi.unstubAllEnvs();
21+
});
22+
23+
it("does not force a platform by default", ({ expect }) => {
24+
expect(getEgressInterceptorPlatform()).toBeUndefined();
25+
});
26+
27+
it("allows overriding the platform", ({ expect }) => {
28+
vi.stubEnv("MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM", "linux/s390x");
29+
30+
expect(getEgressInterceptorPlatform()).toBe("linux/s390x");
31+
});
32+
});
33+
34+
describe("pullEgressInterceptorImage", () => {
35+
beforeEach(() => {
36+
vi.unstubAllEnvs();
37+
vi.mocked(runDockerCmd).mockClear();
38+
});
39+
40+
it("pulls the egress interceptor image without forcing a platform by default", async ({
41+
expect,
42+
}) => {
43+
vi.stubEnv("MINIFLARE_CONTAINER_EGRESS_IMAGE", "proxy-everything:test");
44+
45+
await pullEgressInterceptorImage("docker");
46+
47+
expect(runDockerCmd).toHaveBeenCalledWith("docker", [
48+
"pull",
49+
"proxy-everything:test",
50+
]);
51+
});
52+
53+
it("pulls the egress interceptor image for the configured platform", async ({
54+
expect,
55+
}) => {
56+
vi.stubEnv("MINIFLARE_CONTAINER_EGRESS_IMAGE", "proxy-everything:test");
57+
vi.stubEnv("MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM", "linux/arm64");
58+
59+
await pullEgressInterceptorImage("docker");
60+
61+
expect(runDockerCmd).toHaveBeenCalledWith("docker", [
62+
"pull",
63+
"proxy-everything:test",
64+
"--platform",
65+
"linux/arm64",
66+
]);
67+
});
68+
});

turbo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"WRANGLER_CACHE_DIR",
2121
"CLOUDFLARED_PATH",
2222
"MINIFLARE_CONTAINER_EGRESS_IMAGE",
23+
"MINIFLARE_CONTAINER_EGRESS_IMAGE_PLATFORM",
2324
"WRANGLER_DOCKER_HOST",
2425
"WRANGLER_LOG_PATH",
2526
"WRANGLER_LOG",

0 commit comments

Comments
 (0)