-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrangler.jsonc
More file actions
124 lines (124 loc) · 5.29 KB
/
Copy pathwrangler.jsonc
File metadata and controls
124 lines (124 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
"$schema": "node_modules/wrangler/config-schema.json",
"main": "container-worker.js",
"name": "primalprinting",
"compatibility_date": "2026-04-16",
"compatibility_flags": ["nodejs_compat", "global_fetch_strictly_public"],
// Custom domain routes — kept in code so `wrangler deploy` doesn't wipe
// them on every push (which it does when the local config diverges from
// the dashboard).
"routes": [
{
"pattern": "primalprinting.co.nz",
"zone_name": "primalprinting.co.nz",
"custom_domain": true
},
{
"pattern": "www.primalprinting.co.nz",
"zone_name": "primalprinting.co.nz"
}
],
// Runtime worker env vars (visible to container-worker.js as `env.<NAME>`
// and forwarded to the container env in container-worker.js's
// envVars passthrough). Non-secret values only — secrets stay in the
// dashboard's "Variables and Secrets → Runtime" section.
//
// NEXT_PUBLIC_ASSET_PREFIX must match the build-time value supplied via
// `image_vars` below: build-time controls Next.js's emitted asset URLs;
// runtime controls the entrypoint placeholder swap and any server-side
// reads.
"vars": {
"NEXT_PUBLIC_ASSET_PREFIX": "https://assets.primalprinting.co.nz"
},
"containers": [
{
"class_name": "PrimalPrinting",
"image": "./Dockerfile",
"max_instances": 1,
// Container instance size. Omitting this defaults to the smallest
// "dev" instance (256 MiB RAM, 1/16 vCPU), on which a Next.js +
// Payload CMS standalone server boots slowly and can even OOM on a
// cold start — the Node process is too CPU/RAM-starved to finish
// starting and bind port 3000 before Cloudflare's proxy gives up
// with "Error proxying request to container: Container is taking too
// long to accept the connection; the application could be
// overwhelmed with load". "standard-1" (4 GiB RAM, 1/2 vCPU) gives
// the cold boot enough headroom to start Next.js + open the MongoDB
// pool and bind the port well within the port-ready window. With
// max_instances: 1 (a single low-traffic storefront) the cost delta
// of a larger-but-rarely-cold instance is negligible, and the
// keep-warm cron means it's almost always already running anyway.
//
// NOTE: use "standard-1" (not the legacy "standard" alias, which
// wrangler now warns is deprecated and slated for removal).
"instance_type": "standard-1",
// Non-secret build-time values — passed through to the docker
// build as --build-args. Stored here (not in the dashboard) so
// they're version-controlled and reviewable.
//
// Note: image_vars passes values *literally* — there is NO
// ${VAR} interpolation against the build env. Hardcode strings.
//
// Secrets (TURBO_TOKEN, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY)
// stay in the dashboard's "Build configuration → Variables and
// Secrets". Cloudflare exposes them only to the build script,
// NOT to docker --build-args, so `scripts/cloudflare-build.mts`
// (run via `pnpm run deploy`) substitutes the `${SECRET}`
// placeholders below into image_vars at deploy time.
//
// Keep the dashboard's Build command set to `pnpm run deploy`
// so the substitution always runs.
"image_vars": {
// — Hardcoded non-secrets ——————————————————————————————
"TURBO_TEAM": "primalprinting",
"NEXT_PUBLIC_ASSET_PREFIX": "https://assets.primalprinting.co.nz",
"R2_ASSETS_BUCKET": "primalprinting-assets",
// NEXT_PUBLIC_* discount config baked in at build time. Required
// because client bundles are uploaded to R2 during the build —
// runtime sed-replacement in docker-entrypoint.sh only patches
// the standalone server's local copy, not the bundles served
// from the headless asset CDN. Keep these in sync with the
// runtime defaults in container-worker.js / docker-entrypoint.sh.
"NEXT_PUBLIC_MINIMUM_ITEMS_FOR_DISCOUNT": "2",
"NEXT_PUBLIC_DISCOUNT_PERCENT": "15",
// — Substituted from build-env Secrets at deploy time ——
"R2_S3_ENDPOINT": "${R2_S3_ENDPOINT}",
"R2_ACCESS_KEY_ID": "${R2_ACCESS_KEY_ID}",
"R2_SECRET_ACCESS_KEY": "${R2_SECRET_ACCESS_KEY}",
"TURBO_TOKEN": "${TURBO_TOKEN}",
// Stripe publishable key — must be baked in at build time for
// the same reason as the discount config above (client bundle
// uploaded to R2 during build → runtime sed can't reach it).
// Stored as a Cloudflare Build Secret so the test/live key is
// never committed to source control.
"NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY": "${NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY}"
}
}
],
"durable_objects": {
"bindings": [
{
"class_name": "PrimalPrinting",
"name": "APP"
}
]
},
// Keep-warm Cron Trigger. Fires the Worker's `scheduled` handler (see
// container-worker.js), which pings the container's /api/health endpoint so
// the singleton instance never idles long enough to scale to zero. Every 5
// minutes sits comfortably inside the Container class's `sleepAfter` window,
// so a warm process with a live MongoDB pool is always ready — no cold-start
// connect/init on the first real visitor's critical path.
"triggers": {
"crons": ["*/5 * * * *"]
},
"images": {
"binding": "IMAGES"
},
"migrations": [
{
"tag": "v1",
"new_sqlite_classes": ["PrimalPrinting"]
}
]
}