Space Works Events · Install and run
Free-tier cloud deployment
Documentation index · Configuration · Production release
This guide puts Space Works Events into production on free plans only:
| Piece | Service | Repository file |
|---|---|---|
| Application (Docker) | Render web service, free plan | render.yaml, Dockerfile, scripts/docker-entrypoint.sh |
| PostgreSQL | Supabase, free project | prisma/schema.prisma (url + directUrl) |
| Redis | Upstash, free database | — |
| Object storage | Cloudflare R2, private bucket | — |
| Brevo SMTP relay | — | |
| Scheduler + DNS | Cloudflare Worker cron and DNS | deploy/cloudflare-cron/ |
Every connection is TLS: sslmode=require to Supabase, rediss:// to
Upstash, HTTPS to R2, STARTTLS to Brevo. All variable names are listed in
.env.production.example, which mirrors this
guide.
Pick one region for everything (for example Singapore: Render
singapore, Supabase ap-southeast-1, Upstash ap-southeast-1). Each
request crosses these services several times, so distance adds up.
Keep a password manager entry open while you work and save every value you
create in it. You will paste them into Render once, and Render shows
sync: false prompts only when the Blueprint is first created.
1. Supabase (PostgreSQL)
- Create a project at supabase.com/dashboard. Choose a strong database password (save it) and your region.
- Open the project and click Connect in the top bar. Under
Connection string → URI:
- Transaction pooler (port
6543) is the runtimeDATABASE_URL. Append?pgbouncer=true&connection_limit=5&sslmode=require. - Session pooler (port5432on the samepooler.supabase.comhost) isDIRECT_URL, used only for migrations. Append?sslmode=require.
text
DATABASE_URL=postgresql://postgres.PROJECT-REF:PASSWORD@aws-0-REGION.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=5&sslmode=require
DIRECT_URL=postgresql://postgres.PROJECT-REF:PASSWORD@aws-0-REGION.pooler.supabase.com:5432/postgres?sslmode=require
Why not the "Direct connection" (db.PROJECT-REF.supabase.co)? On the free
plan it is IPv6-only, and Render has no outbound IPv6. The session pooler
supports everything prisma migrate deploy needs (including advisory
locks).
pgbouncer=trueis required on port 6543: a transaction pooler cannot keep Prisma's prepared statements. The preflight and the app's startup check reject a 6543 URL without it.connection_limit=5caps Prisma's pool on the single small instance.connection_limit=1also works but serialises every query, including interactive RSVP transactions.- URL-encode special characters in the password (
@→%40,#→%23,/→%2F). 3. Do not run migrations by hand: the container applies them on start (step 7).
2. Upstash (Redis)
- At console.upstash.com, create a Redis database in your region (free plan, TLS enabled by default; leave eviction off).
- On the database page, copy the TLS connection string for ioredis
(
rediss://default:PASSWORD@NAME.upstash.io:6379). That isREDIS_URL.
Redis is used for distributed rate limits (one Lua call per limited request)
and pub/sub for live ticket check-in. Nothing polls Redis, so an idle instance
uses almost no commands. The cron (step 8) calls /api/internal/outbox once a
minute, which costs one rate-limit command each time, about 45,000 commands a
month.
3. Cloudflare R2 (object storage)
- In the Cloudflare dashboard open R2 Object Storage and create a bucket,
e.g.
spaceworks-events. Leave Public access disabled and do not attach a custom domain: the app serves every image through its own access-checked route. Don't add an object lock or retention rule that keeps deleted objects: the app's deletions must really remove files (storage contract). - R2 → Manage API tokens → Create API token: permission
Object Read & Write, Apply to specific buckets only → your bucket.
Copy the Access Key ID, Secret Access Key and the S3 endpoint
(
https://ACCOUNT-ID.r2.cloudflarestorage.com; drop any bucket path).
text
S3_BUCKET=spaceworks-events
S3_REGION=auto
S3_ENDPOINT=https://ACCOUNT-ID.r2.cloudflarestorage.com
S3_ACCESS_KEY_ID=...
S3_SECRET_ACCESS_KEY=...
S3_FORCE_PATH_STYLE=1
4. Brevo (email)
- Create a Brevo account. Under Senders, Domains & Dedicated IPs →
Domains, add your domain and publish the records Brevo shows (a
brevo-codeTXT, the DKIM records, and a DMARC TXT such asv=DMARC1; p=none; rua=mailto:dmarc@YOUR-DOMAIN). If the domain already has an SPF record, mergeinclude:spf.brevo.cominto it rather than adding a second one. Wait until Brevo shows the domain as authenticated. - Settings → SMTP & API → SMTP: note the SMTP login
(
…@smtp-brevo.com) and Generate a new SMTP key.
text
EMAIL_FROM=Space Works Events <events@YOUR-DOMAIN>
SMTP_HOST=smtp-relay.brevo.com
SMTP_PORT=2525
SMTP_SECURE=false
SMTP_USER=YOUR-LOGIN@smtp-brevo.com
SMTP_PASSWORD=YOUR-SMTP-KEY
Port 2525, not 587: Render free web services block outbound traffic to ports 25, 465 and 587. Brevo accepts STARTTLS on 2525, and the app requires TLS with certificate verification on production SMTP. On a paid Render instance or another host, 587 works too.
EMAIL_FROM must use the authenticated domain. These environment values are
the bootstrap/fallback; after the first login you can move SMTP into
Super admin → Settings, where the key is stored encrypted.
5. Generate secrets
Render's Blueprint generates AUTH_SECRET, CRON_SECRET and
HEALTHCHECK_SECRET for you. Generate the two AES keys yourself; each must be
base64 of exactly 32 bytes:
openssl rand -base64 32 # NEXT_SERVER_ACTIONS_ENCRYPTION_KEY
openssl rand -base64 32 # MFA_ENCRYPTION_KEY (a different value)
Store both in your password manager.
NEXT_SERVER_ACTIONS_ENCRYPTION_KEYis used by the build and at runtime. Changing it needs a redeploy and invalidates open forms.- Losing
MFA_ENCRYPTION_KEYmakes every enrolled authenticator, and the encrypted SMTP/Google settings, unreadable. Never rotate it casually.
Not using the Blueprint? Generate the other three with
openssl rand -base64 32 as well.
6. Check the configuration locally (optional)
Put the values in an owner-only file outside the repository and run the same preflight CI runs:
umask 077 && cp .env.production.example /secure/path/swevents.env # then edit it
node --env-file=/secure/path/swevents.env scripts/check-production-env.mjs
It must print Production environment preflight passed.
7. Render (application)
- Push the repository to GitHub (
SpaceWorks-Labs/SpaceWorks-Events). - In Render choose New → Blueprint, connect the repository, and select
the branch to deploy. Render reads
render.yaml: one Docker web service, free plan, health check/api/health. - Fill in every prompted (
sync: false) value. For the first deploy without a custom domain, usehttps://spaceworks-events.onrender.com(your service URL) for bothAUTH_URLandNEXT_PUBLIC_BASE_URL. If that subdomain is taken, Render adds a suffix: after the service is created, check its real URL on the service page, set both values to it, and run Manual Deploy → Clear build cache & deploy (the base URL is baked in at build time). - Click Apply. The first build takes about 10 minutes. On start the
container runs
prisma migrate deployagainstDIRECT_URL(MIGRATE_ON_START=1), then starts the server. If a migration fails, the container exits, the deploy fails its health check, and the previous version keeps serving. Migrations also run on every wake from sleep (a no-op when nothing is pending, a few seconds on the free CPU), and if Supabase is paused or unreachable the container cannot start at all. Render's free plan has no pre-deploy command, so before deploying a release that reserves new organisation addresses (0.11.0 does), run the read-only check in the Supabase SQL editor or withnode scripts/check-reserved-slugs.mjsand rename any organisation it names (Reserved organisation addresses).
How the Blueprint fits the free plan:
- Build args. Render passes every environment variable to
docker buildas a build argument. The Dockerfile declares onlyNEXT_PUBLIC_BASE_URLandNEXT_SERVER_ACTIONS_ENCRYPTION_KEY, so nothing else enters the build. The key exists only in the builder stage's metadata and cache, never in the final image. Where BuildKit secrets are available (local Docker, GitHub Actions, Compose) the secret mount is used instead; a Render secret file namedNEXT_SERVER_ACTIONS_ENCRYPTION_KEYworks the same way if you prefer. - Memory.
NODE_OPTIONS=--max-old-space-size=384keeps the heap inside the 512 MB instance. It applies only at runtime; the build runs on Render's separate build machines. - Deploys.
autoDeployTrigger: checksPassdeploys a commit only after its GitHub checks pass, andbuildFilterskips doc-only commits. Builds count against the workspace's monthly build minutes. - Changing
NEXT_PUBLIC_BASE_URL(for example when adding the custom domain) needs Manual Deploy → Clear build cache & deploy, because the value is compiled into the client bundle. UpdateAUTH_URLto the same value at the same time.
8. Cloudflare DNS and the cron Worker
Custom domain
- Add the domain in Render (Settings → Custom Domains), e.g.
events.YOUR-DOMAIN. - In Cloudflare DNS add
CNAME events → spaceworks-events.onrender.comwith Proxy status: DNS only, and remove anyAAAArecord for that name (Render has no IPv6). Set SSL/TLS → Overview to Full. - Wait for Render to show the certificate as issued. Then set
AUTH_URLandNEXT_PUBLIC_BASE_URLtohttps://events.YOUR-DOMAINand redeploy with a cleared build cache. - Optional: switch the record to Proxied (orange cloud) for Cloudflare's
WAF/CDN. Then:
- set
TRUSTED_PROXY_IP_HEADER=cf-connecting-ip(Cloudflare overwrites it). With DNS only, keepx-forwarded-for. - turn off Scrape Shield → Email Address Obfuscation for the hostname (it injects a script the CSP blocks). - theonrender.comURL stays reachable and bypasses Cloudflare. Rate limits stay in force there; they just key on the forwarded header.
Scheduler Worker
The free Render instance runs everything in one process
(SWE_PROCESS_ROLE=all). It sleeps after 15 minutes without traffic, which
also stops its email worker and timed jobs. The Worker in
deploy/cloudflare-cron runs every
minute, wakes the app through /api/health, then calls
POST /api/internal/outbox with Authorization: Bearer $CRON_SECRET.
cd deploy/cloudflare-cron
npm ci
npx wrangler login
npx wrangler secret put APP_URL # https://events.YOUR-DOMAIN (no trailing slash)
npx wrangler secret put CRON_SECRET # copy the value from Render → Environment
npx wrangler deploy
npx wrangler tail # expect "health 200" and "outbox 200" each minute
outbox 404 means the Worker's CRON_SECRET does not match the app's.
9. First super-admin login
- Set the super-admin password from your computer, with the database's
direct connection string (Supabase → Connect → Session pooler):
DATABASE_URL="postgresql://..." NEXT_PUBLIC_BASE_URL=https://events.YOUR-DOMAIN node docker/vps/recover-super-admin.mjs you@example.comfrom a checkout of this repository afternpm ci. It creates the account and prints a one-hour link to set its password; run it again to reset the password. The super-admin address can't sign up, use forgot password or change its password in the app. - Sign in with the email and password. We recommend you then open
/account/securityand enrol an authenticator app, which is then asked for at every sign-in. Save the recovery codes. - Open
/super-admin(there is no separate step-up) and review Settings: send a test email, and optionally configure Google SSO (callbackhttps://events.YOUR-DOMAIN/api/auth/callback/google).
10. Verify
curl -fsS https://events.YOUR-DOMAIN/api/health
curl -fsS -H "Authorization: Bearer $HEALTHCHECK_SECRET" https://events.YOUR-DOMAIN/api/health/db
Both should return {"ok":true,…}. A 404 from /api/health/db means the
bearer value is wrong. Then create a test event, register for it, and check
that the ticket email arrives, the cover image uploads (R2), and checking the
ticket in updates the attendee's open ticket page live (Upstash pub/sub).
Free-tier limits to know
Quotas change, so check each provider's pricing page.
| Service | Limit that matters | What it means here |
|---|---|---|
| Render free | 512 MB RAM, 0.1 CPU; sleeps after 15 idle minutes; 750 instance hours per workspace per month; outbound SMTP 25/465/587 blocked; no pre-deploy command, shell or disk | Cold starts take about 30–60 s. The per-minute Worker keeps the instance awake (about 744 h a month), which uses nearly the whole allowance: run only this one free service in the workspace. CPU is slow for PDF and image work; upgrade the instance for real events. |
| Supabase free | 500 MB database; paused after 7 days without activity; two free projects; no downloadable backups | The per-minute outbox run queries the database, which keeps the project active. If it is ever paused, restore it from the dashboard. Take your own backups (below). |
| Upstash free | Monthly command budget and 256 MB data | Rate limits and check-in pub/sub only; about 45,000 commands a month go to the cron. |
| Cloudflare R2 free | 10 GB storage plus monthly Class A/B operation allowances; no egress fees | Cover images, logos and certificate art are small WebP files. |
| Brevo free | 300 emails per day | Broadcasts to large events will queue for days. Upgrade before a big send. |
| Cloudflare Workers free | 100,000 requests per day | The cron uses about 1,440 runs a day. |
Backups
Supabase's free plan has no downloadable backups. From a trusted machine with PostgreSQL client tools at least as new as the Supabase server, take one regularly through the session pooler:
DATABASE_URL="$DIRECT_URL" npm run db:backup
Copy the archive to a second private bucket with the --s3-* options
described in Production operations.
From SpaceWorks-Events/docs/DEPLOYMENT_CLOUD.md at 4e3cf5a, updated 2026-10-30. Suggest a change