Skip to content

Commit 974cf07

Browse files
committed
fix socket config in vite plugin
1 parent 83e4a55 commit 974cf07

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.changeset/yummy-coins-greet.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@cloudflare/vite-plugin": patch
3+
---
4+
5+
fix: properly set the docker socket path in the vite plugin
6+
7+
Previously, this was only picking up the value set in Wrangler config under `dev.containerEngine`, but this value can also be set from env vars or automatically read from the current docker context.

packages/vite-plugin-cloudflare/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as path from "node:path";
44
import {
55
generateContainerBuildId,
66
getContainerIdsByImageTags,
7+
resolveDockerHost,
78
} from "@cloudflare/containers-shared/src/utils";
89
import { generateStaticRoutingRuleMatcher } from "@cloudflare/workers-shared/asset-worker/src/utils/rules-engine";
910
import replace from "@rollup/plugin-replace";
@@ -370,9 +371,12 @@ if (import.meta.hot) {
370371
const hasDevContainers =
371372
entryWorkerConfig?.containers?.length &&
372373
entryWorkerConfig.dev.enable_containers;
374+
const dockerPath = getDockerPath();
373375

374376
if (hasDevContainers) {
375377
containerBuildId = generateContainerBuildId();
378+
entryWorkerConfig.dev.container_engine =
379+
resolveDockerHost(dockerPath);
376380
}
377381

378382
const miniflareDevOptions = await getDevMiniflareOptions({
@@ -445,8 +449,6 @@ if (import.meta.hot) {
445449
}
446450

447451
if (hasDevContainers) {
448-
const dockerPath = getDockerPath();
449-
450452
containerImageTagsSeen = await prepareContainerImages({
451453
containersConfig: entryWorkerConfig.containers,
452454
containerBuildId,

0 commit comments

Comments
 (0)