Skip to content

Open source alternative to Semrush and Ahrefs

fix(self-host): unbreak the Deploy to Cloudflare button and its build (#412)

Ben Senescu3a94f02a5573
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index afff891a..6f100b98 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -43,8 +43,6 @@ jobs:
# worker's eager startup graph. See vite-plugin-lean-worker-bundle.ts.
- name: Build worker (eager-bundle guard)
run: pnpm vite build
- env:
- NODE_OPTIONS: --max-old-space-size=4096
- name: Install website dependencies
run: pnpm --dir web install --frozen-lockfile
diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml
index 38f8c6fa..2fbf6a8d 100644
--- a/.github/workflows/pr-preview.yml
+++ b/.github/workflows/pr-preview.yml
@@ -93,8 +93,6 @@ jobs:
- name: Deploy preview stage
if: github.event.action != 'closed'
run: pnpm deploy:preview --stage "$STAGE" --yes
- env:
- NODE_OPTIONS: --max-old-space-size=4096
# Fail the job (and skip the URL comment) if the deployed preview
# answers without a Cloudflare Access login redirect. A definitive app
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 00000000..bc68311d
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1,6 @@
+# The SSR vite build needs more than Node's ~2 GiB default heap. pnpm passes
+# this to every script via NODE_OPTIONS, which covers `pnpm run build` wherever
+# it runs — the Deploy to Cloudflare builder, self-hosters, and local checkouts
+# — without each environment having to remember to set it (CI and the Docker
+# image already did; this makes it universal).
+node-options=--max-old-space-size=4096
diff --git a/Dockerfile.selfhost b/Dockerfile.selfhost
index 06ebe104..f44eb1a9 100644
--- a/Dockerfile.selfhost
+++ b/Dockerfile.selfhost
@@ -18,6 +18,7 @@ EXPOSE 3001
# The build MUST run at container start, not image-build time: AUTH_MODE (and the
# other client envs) are inlined into the client bundle by `vite build`, and the
# self-hoster only chooses AUTH_MODE at runtime via Compose. Building here lets
-# that runtime value bake into the bundle. NODE_OPTIONS raises the V8 heap ceiling
-# so the SSR build of ~7400 modules doesn't OOM under Node's ~2GB default.
-CMD ["sh", "-c", "echo 'OpenSEO sends an anonymous usage heartbeat (counts only). Disable: OPENSEO_TELEMETRY_DISABLED=1. Details: docs/SELF_HOSTING_DOCKER.md#telemetry' && pnpm run db:migrate:local && NODE_OPTIONS=--max-old-space-size=4096 pnpm run build && pnpm exec vite preview --host 0.0.0.0 --port ${PORT:-3001}"]
+# that runtime value bake into the bundle. The repo .npmrc raises the V8 heap
+# ceiling (node-options) so the ~7400-module SSR build doesn't OOM under Node's
+# ~2GB default.
+CMD ["sh", "-c", "echo 'OpenSEO sends an anonymous usage heartbeat (counts only). Disable: OPENSEO_TELEMETRY_DISABLED=1. Details: docs/SELF_HOSTING_DOCKER.md#telemetry' && pnpm run db:migrate:local && pnpm run build && pnpm exec vite preview --host 0.0.0.0 --port ${PORT:-3001}"]
diff --git a/docs/LOCAL_POSTGRES.md b/docs/LOCAL_POSTGRES.md
index bce75641..0af736c8 100644
--- a/docs/LOCAL_POSTGRES.md
+++ b/docs/LOCAL_POSTGRES.md
@@ -62,12 +62,14 @@ provider flag there (not just in your shell):
DATABASE_PROVIDER=postgres
```
-The connection string comes from the `HYPERDRIVE` binding: in local dev,
-miniflare resolves it to the `localConnectionString` committed in
-`wrangler.jsonc`, which already points at the Docker container from step 1.
-(In deployed Workers the same binding resolves to real Hyperdrive — the app
-never connects to Postgres except through this binding.) If your local Postgres
-lives elsewhere, override without touching the config:
+The connection string comes from the `HYPERDRIVE` binding. The `hyperdrive`
+block in `wrangler.jsonc` ships commented out (an active block makes the
+"Deploy to Cloudflare" button demand a Postgres connection string), so
+uncomment it first. Miniflare then resolves the binding to its
+`localConnectionString`, which already points at the Docker container from
+step 1. (In deployed Workers the same binding resolves to real Hyperdrive —
+the app never connects to Postgres except through this binding.) If your local
+Postgres lives elsewhere, override without touching the config:
```sh
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE=postgres://... pnpm dev
diff --git a/wrangler.jsonc b/wrangler.jsonc
index 5a192a40..b231a13b 100644
--- a/wrangler.jsonc
+++ b/wrangler.jsonc
@@ -94,16 +94,17 @@
// docs/LOCAL_POSTGRES.md, and nothing connects to it unless
// DATABASE_PROVIDER=postgres is set in .env.local.
//
- // Running raw `wrangler deploy` against another account? DELETE this block —
- // the id lives in OpenSEO's account and the deploy fails without access to
- // it. (Alchemy deploys and the Docker image never read it.)
- "hyperdrive": [
- {
- "binding": "HYPERDRIVE",
- "id": "9d64ccfb559f44449ce52a143912f898",
- "localConnectionString": "postgres://openseo:openseo@localhost:5433/openseo",
- },
- ],
+ // Kept commented out: an active hyperdrive block makes the "Deploy to
+ // Cloudflare" button demand a Postgres connection string, and the id lives in
+ // OpenSEO's account anyway (Alchemy deploys and the Docker image never read
+ // it). Uncomment when running local Postgres dev per docs/LOCAL_POSTGRES.md.
+ // "hyperdrive": [
+ // {
+ // "binding": "HYPERDRIVE",
+ // "id": "9d64ccfb559f44449ce52a143912f898",
+ // "localConnectionString": "postgres://openseo:openseo@localhost:5433/openseo",
+ // },
+ // ],
"r2_buckets": [
{
"bucket_name": "open-seo",