Skip to main content
Deploy Banana Slides publicly with minimal cost, scale-to-zero Python execution, persistent S3-compatible file storage, and managed PostgreSQL.

Architecture & Cost Overview

Container disks on Cloudflare Containers are ephemeral when an instance sleeps. Never keep SQLite or uploaded files on container-local disk in production — always use DATABASE_URL (PostgreSQL) and R2 FUSE mounting (/app/uploads).

First-Time Setup

1

Provision Supabase PostgreSQL (Singapore)

  1. Create a Supabase project in ap-southeast-1 and set an alphanumeric database password (avoid @, #, %, & so URI parsing stays clean).
  2. Create the 11 application tables + alembic_version (stamped to the current Alembic head) and enable Row Level Security (RLS) on every table in public.
  3. Revoke Data API access from anon and authenticated roles since only the Flask backend connects via Postgres:
  4. Copy the Session pooler URI (port 5432, IPv4-compatible) from Connect → Session pooler.
2

Enable Cloudflare R2 & Create S3 API Token

  1. Enable R2 Object Storage in the Cloudflare Dashboard and create a bucket (e.g. banana-slides-storage in APAC).
  2. Go to R2 → Manage API Tokens → Create Account API token, grant Object Read & Write scoped to that bucket, and save the Access Key ID and Secret Access Key.
3

Enable Workers Paid & Google OAuth

  1. Upgrade Cloudflare Workers to Workers Paid ($5/month) to unlock Cloudflare Containers and Durable Objects.
  2. In Google Cloud Console, add your Cloudflare Pages URL (and any custom domain) under Authorized JavaScript origins for your OAuth 2.0 Client ID.
4

Deploy the Backend Container

Ensure Docker Desktop is running locally, then deploy from cloudflare-backend/:
cloudflare-backend/package.json pins wrangler@4.85.0 so it works on Node.js 20.18+. If your machine runs Node.js 22.12+, you may use newer Wrangler 4 releases.
Upload runtime secrets to the Worker (pass the variable name in the command, and paste the value at the prompt):
5

Connect Cloudflare Pages (Frontend)

  1. Create a Cloudflare Pages project linked to your GitHub repository:
    • Production branch: main
    • Root directory: frontend
    • Build command: npm run build:web
    • Build output directory: dist
  2. Under Settings → Variables and secrets (both Production and Preview), set BACKEND_ORIGIN to your Worker URL (https://banana-slides-backend.<subdomain>.workers.dev).
  3. Verify GitHub App repository permissions so pushes to main trigger automatic builds.

Day-2 Updates & Redeployment

Use the automated helper script from the repository root whenever you update backend Python code or container configuration:
The script automatically verifies:
  1. Docker Desktop is running.
  2. cloudflare-backend/entrypoint.sh uses Unix LF line endings (required for Linux containers).
  3. npm --prefix cloudflare-backend run typecheck passes with 0 errors.
  4. npx wrangler deploy pushes any container/Worker changes.
  5. Public endpoints (/, /health, /api/auth/config, /api/output-language, /llms.txt, /robots.txt) return HTTP 200, and POST /api/auth/dev-login returns 403.
To run live endpoint checks only without rebuilding:
  1. Add your domain under Cloudflare Pages → Custom domains.
  2. Add https://yourdomain.com to Google Cloud Console Authorized JavaScript origins.
  3. Update the CORS_ORIGINS Worker secret (npx wrangler secret put CORS_ORIGINS) to include https://yourdomain.com.
  4. Replace yourdomain.com in frontend/public/sitemap.xml and push to main.
  5. In Cloudflare Dashboard Security → Bots, ensure search & AI crawlers (Googlebot, OAI-SearchBot, GPTBot, PerplexityBot, ClaudeBot) are not blocked.

Detailed Reference

For full architecture notes, Alembic PostgreSQL migration guidelines, and troubleshooting (error 1101 cold-start tuning, CRLF guard, IPv4 pooler, DEV_LOGIN_DISABLED), see docs/deploy-cloudflare-supabase.md.