dazzling-branch-75889
05/01/2026, 5:01 PMhallowed-baker-22997
05/01/2026, 7:44 PMhallowed-baker-22997
05/01/2026, 7:47 PMimport * as pulumi from "@pulumi/pulumi";
import * as command from "@pulumi/command";
import * as fs from "fs";
// The wrangler project lives alongside or within the Pulumi project
const workerDir = "./my-container-worker";
// Hash the source files so the command re-runs on changes
const sourceHash = pulumi.output(
fs.readdirSync(workerDir)
.filter(f => f.match(/\.(ts|js|jsonc?)$/))
.map(f => fs.readFileSync(`${workerDir}/${f}`, "utf-8"))
.join("\n")
).apply(s => require("crypto").createHash("sha256").update(s).digest("hex"));
const deploy = new command.local.Command("container-worker", {
dir: workerDir,
create: "wrangler deploy",
update: "wrangler deploy",
delete: "wrangler delete",
environment: {
CLOUDFLARE_API_TOKEN: cfg.requireSecret("cloudflareApiToken"),
},
triggers: [sourceHash],
});
And the corresponding wrangler.jsonc in ./my-container-worker/:
{
"name": "my-container-worker",
"main": "src/index.ts",
"compatibility_date": "2025-04-01",
"durable_objects": {
"bindings": [
{
"name": "MY_CONTAINER",
"class_name": "MyContainer"
}
]
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": [
"MyContainer"
]
}
],
"containers": [
{
"class_name": "MyContainer",
"image": "docker.io/library/nginx:latest",
"instance_type": "basic",
"max_instances": 5
}
]
}
this will it'll automatically run wrangler deploy for you when you pulumi up and your container definition has changed.dazzling-branch-75889
05/02/2026, 12:36 AMhallowed-baker-22997
05/02/2026, 12:55 AMdazzling-branch-75889
05/02/2026, 12:59 AM