Skip to content

Commit de65c58

Browse files
gabivljemily-shen
andauthored
containers: Remove experimental flag from enabling egress interception for containers (#12826)
Co-authored-by: emily-shen <eshen@cloudflare.com>
1 parent cd16fdb commit de65c58

8 files changed

Lines changed: 19 additions & 29 deletions

File tree

.changeset/funny-mails-hammer.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"wrangler": minor
3+
"miniflare": minor
4+
"@cloudflare/vite-plugin": minor
5+
---
6+
7+
Enable container egress interception in local dev without the `experimental` compatibility flag
8+
9+
Container local development now always prepares the egress interceptor sidecar image needed for `interceptOutboundHttp()`. This makes container-to-Worker interception available by default in Wrangler, Miniflare, and the Cloudflare Vite plugin.

packages/containers-shared/src/images.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import type {
1717
WranglerLogger,
1818
} from "./types";
1919

20-
const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE =
21-
"cloudflare/proxy-everything:4dc6c7f@sha256:9621ef445ef120409e5d95bbd845ab2fa0f613636b59a01d998f5704f4096ae2";
20+
export const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE =
21+
"cloudflare/proxy-everything:3f5e832@sha256:816255f5b6ebdc2cdcddb578d803121e7ee9cfe178442da07725d75a66cdcf37";
2222

2323
export function getEgressInterceptorImage(): string {
2424
return (
@@ -114,7 +114,6 @@ export async function prepareContainerImagesForDev(args: {
114114
}) => void;
115115
logger: WranglerLogger | ViteLogger;
116116
isVite: boolean;
117-
compatibilityFlags?: string[];
118117
}): Promise<void> {
119118
const {
120119
dockerPath,
@@ -171,10 +170,9 @@ export async function prepareContainerImagesForDev(args: {
171170
}
172171
}
173172

174-
// Pull the egress interceptor image if experimental flag is enabled.
175-
// This image is used to intercept outbound HTTP from containers and
176-
// route it back to workerd (e.g. for interceptOutboundHttp).
177-
if (!aborted && args.compatibilityFlags?.includes("experimental")) {
173+
// Pull the egress interceptor image used to intercept outbound HTTP from
174+
// containers and route it back to workerd (e.g. for interceptOutboundHttp).
175+
if (!aborted) {
178176
await pullEgressInterceptorImage(dockerPath);
179177
}
180178
}

packages/miniflare/src/plugins/core/index.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from "node:path";
55
import { Readable } from "node:stream";
66
import tls from "node:tls";
77
import { TextEncoder } from "node:util";
8+
import { DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE } from "@cloudflare/containers-shared";
89
import { bold } from "kleur/colors";
910
import { MockAgent } from "undici";
1011
import SCRIPT_ENTRY from "worker:core/entry";
@@ -908,10 +909,7 @@ export const CORE_PLUGIN: Plugin<
908909
);
909910
}
910911
),
911-
containerEngine: getContainerEngine(
912-
options.containerEngine,
913-
options.compatibilityFlags
914-
),
912+
containerEngine: getContainerEngine(options.containerEngine),
915913
},
916914
});
917915
}
@@ -1214,9 +1212,6 @@ function getWorkerScript(
12141212
}
12151213
}
12161214

1217-
const DEFAULT_CONTAINER_EGRESS_INTERCEPTOR_IMAGE =
1218-
"cloudflare/proxy-everything:4dc6c7f@sha256:9621ef445ef120409e5d95bbd845ab2fa0f613636b59a01d998f5704f4096ae2";
1219-
12201215
/**
12211216
* Returns the default containerEgressInterceptorImage. It's used for
12221217
* container network interception for local dev.
@@ -1234,8 +1229,7 @@ function getContainerEgressInterceptorImage(): string {
12341229
* @returns The container engine, defaulting to the default docker socket located on linux/macOS at `unix:///var/run/docker.sock`
12351230
*/
12361231
function getContainerEngine(
1237-
engineOrSocketPath: Worker_ContainerEngine | string | undefined,
1238-
compatibilityFlags?: string[]
1232+
engineOrSocketPath: Worker_ContainerEngine | string | undefined
12391233
): Worker_ContainerEngine {
12401234
if (!engineOrSocketPath) {
12411235
// TODO: workerd does not support win named pipes
@@ -1245,13 +1239,10 @@ function getContainerEngine(
12451239
: "unix:///var/run/docker.sock";
12461240
}
12471241

1248-
// TODO: Once the feature becomes GA, we should remove the experimental requirement.
12491242
// Egress interceptor is to support direct connectivity between the Container and Workers,
12501243
// it spawns a container in the same network namespace as the local dev container and
12511244
// intercepts traffic to redirect to Workerd.
1252-
const egressImage = compatibilityFlags?.includes("experimental")
1253-
? getContainerEgressInterceptorImage()
1254-
: undefined;
1245+
const egressImage = getContainerEgressInterceptorImage();
12551246

12561247
if (typeof engineOrSocketPath === "string") {
12571248
return {

packages/vite-plugin-cloudflare/src/plugins/dev.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,6 @@ export const devPlugin = createPlugin("dev", (ctx) => {
208208
onContainerImagePreparationEnd: () => {},
209209
logger: viteDevServer.config.logger,
210210
isVite: true,
211-
compatibilityFlags: ctx.allWorkerConfigs.flatMap(
212-
(c) => c.compatibility_flags
213-
),
214211
});
215212

216213
containerImageTags = new Set(containerTagToOptionsMap.keys());

packages/vite-plugin-cloudflare/src/plugins/preview.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ export const previewPlugin = createPlugin("preview", (ctx) => {
4949
onContainerImagePreparationEnd: () => {},
5050
logger: vitePreviewServer.config.logger,
5151
isVite: true,
52-
compatibilityFlags: ctx.allWorkerConfigs.flatMap(
53-
(c) => c.compatibility_flags
54-
),
5552
});
5653

5754
const containerImageTags = new Set(containerTagToOptionsMap.keys());

packages/wrangler/e2e/containers.dev.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ for (const source of imageSource) {
4747
name: `${workerName}`,
4848
main: "src/index.ts",
4949
compatibility_date: "2025-04-03",
50-
compatibility_flags: ["experimental", "enable_ctx_exports"],
50+
compatibility_flags: ["enable_ctx_exports"],
5151
containers: [
5252
{
5353
image: "./Dockerfile",

packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ export class LocalRuntimeController extends RuntimeController {
270270
},
271271
logger: logger,
272272
isVite: false,
273-
compatibilityFlags: data.config.compatibilityFlags,
274273
});
275274
if (this.containerBeingBuilt) {
276275
this.containerBeingBuilt.abortRequested = false;

packages/wrangler/src/api/startDevWorker/MultiworkerRuntimeController.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ export class MultiworkerRuntimeController extends LocalRuntimeController {
168168
},
169169
logger: logger,
170170
isVite: false,
171-
compatibilityFlags: data.config.compatibilityFlags,
172171
});
173172
if (this.containerBeingBuilt) {
174173
this.containerBeingBuilt.abortRequested = false;

0 commit comments

Comments
 (0)