Skip to content

Commit 2dc3642

Browse files
committed
fix(wrangler): drop image_vars block — values were passed through literally
The image_vars field in wrangler.jsonc passes string values *literally* to the docker build — there is no ${VAR} interpolation against the Cloudflare Workers Build env. As a result, every entry like "TURBO_TEAM": "${TURBO_TEAM}" was forwarding the literal seven-character string '${TURBO_TEAM}' as a docker --build-arg, which the Dockerfile's ENV statement faithfully captured, and the build-step script then had to strip back out. Cloudflare Workers Builds *does* automatically forward every variable defined in 'Build configuration → Variables and Secrets' as a 'docker build --build-arg', which the matching ARG declarations in the Dockerfile pick up by name. So we don't need image_vars at all — drop the whole block to remove the dead-string injection. Required Cloudflare Build env vars are now documented inline in wrangler.jsonc instead.
1 parent aa11c52 commit 2dc3642

1 file changed

Lines changed: 21 additions & 36 deletions

File tree

wrangler.jsonc

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,30 @@
3535
"class_name": "PrimalPrinting",
3636
"image": "./Dockerfile",
3737
"max_instances": 1,
38-
// Forward Turborepo Remote Cache credentials from the Cloudflare
39-
// Workers Build environment into the container build as
40-
// docker `--build-arg` values. The ${VAR} placeholders are
41-
// substituted by wrangler at deploy time from the build env, so
42-
// no secret values are ever committed to this file.
38+
// Non-secret build-time values — passed through to the docker
39+
// build as --build-args. Stored here (not in the dashboard) so
40+
// they're version-controlled and reviewable.
4341
//
44-
// Only the two vars actually needed for Vercel-hosted Remote
45-
// Cache are listed here. If you self-host or sign cache
46-
// artefacts, add `"TURBO_API": "${TURBO_API}"` and/or
47-
// `"TURBO_REMOTE_CACHE_SIGNATURE_KEY": "${TURBO_REMOTE_CACHE_SIGNATURE_KEY}"`
48-
// once those env vars are set in the Cloudflare build env —
49-
// referencing an unset env var here makes wrangler pass through
50-
// the literal "${TURBO_API}" string, which Turbo then treats as
51-
// a (broken) cache URL.
42+
// Note: image_vars passes values *literally* — there is NO
43+
// ${VAR} interpolation against the build env. Hardcode strings.
5244
//
53-
// Configure these in the Cloudflare dashboard:
54-
// Workers & Pages → primalprinting → Settings → Builds →
55-
// Variables and Secrets
56-
// (mark TURBO_TOKEN, R2_SECRET_ACCESS_KEY as "Secret")
57-
//
58-
// R2_* vars feed the build-time `pnpm upload-assets` step that
59-
// mirrors .next/static + public/ to the assets bucket so Next's
60-
// `assetPrefix` can serve them from the CDN. They reuse the
61-
// same R2 credentials already configured for runtime media
62-
// access — only the bucket differs (R2_ASSETS_BUCKET).
63-
//
64-
// NEXT_PUBLIC_ASSET_PREFIX is baked into the client bundle at
65-
// build time (Next inlines NEXT_PUBLIC_* vars). The runtime
66-
// value is also injected via the worker env passthrough in
67-
// container-worker.js so the entrypoint placeholder swap can
68-
// re-target a different CDN per deploy if needed.
45+
// Secrets (TURBO_TOKEN, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY)
46+
// stay in the dashboard's "Build configuration → Variables and
47+
// Secrets" — Cloudflare auto-forwards them as --build-args
48+
// alongside these.
6949
"image_vars": {
70-
"TURBO_TEAM": "${TURBO_TEAM}",
71-
"TURBO_TOKEN": "${TURBO_TOKEN}",
72-
"NEXT_PUBLIC_ASSET_PREFIX": "${NEXT_PUBLIC_ASSET_PREFIX}",
73-
"R2_ASSETS_BUCKET": "${R2_ASSETS_BUCKET}",
74-
"R2_S3_ENDPOINT": "${R2_S3_ENDPOINT}",
75-
"R2_ACCESS_KEY_ID": "${R2_ACCESS_KEY_ID}",
76-
"R2_SECRET_ACCESS_KEY": "${R2_SECRET_ACCESS_KEY}"
50+
// Vercel team ID for Turborepo Remote Cache. TURBO_TEAMID
51+
// accepts the team_… form; use TURBO_TEAM if you'd rather
52+
// supply the slug.
53+
"TURBO_TEAMID": "team_ATZPkCXiYj2fRXGwHYQ1Zd27",
54+
// Headless asset hosting — Next inlines NEXT_PUBLIC_* vars
55+
// at build time, so this needs to be the build-time value.
56+
// The matching runtime value is set in `vars` above so the
57+
// container env passthrough has the same value.
58+
"NEXT_PUBLIC_ASSET_PREFIX": "https://assets.primalprinting.co.nz",
59+
// R2 assets bucket name. The matching access keys + S3
60+
// endpoint live in the dashboard as Secrets.
61+
"R2_ASSETS_BUCKET": "primalprinting-assets"
7762
}
7863
}
7964
],

0 commit comments

Comments
 (0)