Skip to content

Deployment

Alex Neamtu edited this page Jan 15, 2026 · 1 revision

Deployment

htoprc.dev runs on Cloudflare's free tier.

Infrastructure

Component Service
Frontend Cloudflare Pages
API Cloudflare Workers
Database Cloudflare D1 (SQLite)
Auth Clerk
DNS Cloudflare

Prerequisites

  1. Cloudflare account
  2. Clerk account (optional, for auth)
  3. GitHub account (for scraper token)

Setup

1. Clone and Install

git clone https://github.com/alexneamtu/htoprc.dev.git
cd htoprc.dev
pnpm install

2. Cloudflare Login

pnpm exec wrangler login

3. Create D1 Database

# Create databases
pnpm exec wrangler d1 create htoprc-db-staging
pnpm exec wrangler d1 create htoprc-db-production

# Update wrangler.toml with the database IDs

4. Apply Migrations

# Staging
pnpm exec wrangler d1 migrations apply DB --env staging --remote

# Production
pnpm exec wrangler d1 migrations apply DB --env production --remote

5. Set Secrets

# Clerk (optional)
pnpm exec wrangler secret put CLERK_SECRET_KEY --env staging
pnpm exec wrangler secret put CLERK_SECRET_KEY --env production

# GitHub token (for scraper)
pnpm exec wrangler secret put GITHUB_TOKEN --env production

6. Deploy

# Deploy API
pnpm exec wrangler deploy --env staging
pnpm exec wrangler deploy --env production

# Deploy Web (via Pages)
pnpm exec wrangler pages deploy apps/web/dist --project-name=htoprc-staging
pnpm exec wrangler pages deploy apps/web/dist --project-name=htoprc-production

Environment Variables

API (Cloudflare Workers)

Set via wrangler secret:

  • CLERK_SECRET_KEY - Clerk API key
  • GITHUB_TOKEN - GitHub API token

Web (Cloudflare Pages)

Set in Pages dashboard or .env:

  • VITE_API_URL - API endpoint URL
  • VITE_CLERK_PUBLISHABLE_KEY - Clerk public key

CI/CD

GitHub Actions automatically:

  1. Run tests on PR
  2. Deploy to production on merge to main
  3. Create GitHub Release with changelog

See .github/workflows/ for workflow definitions.

Custom Domains

Configure in Cloudflare dashboard:

  • Pages: Add custom domain in project settings
  • Workers: Add route in wrangler.toml

Costs

Resource Free Tier
Workers requests 100K/day
D1 reads 5M/day
D1 writes 100K/day
Pages bandwidth Unlimited

The project runs entirely on free tier for typical usage.

Clone this wiki locally