Prologue
An idea in localhost is not a product.
Shipping is the moment a project starts earning trust — or losing it. This chapter is a boring, checklist-driven guide to launching AI apps that stay up, stay cheap, and stay observable.
Part I · Choose
1. Where to Deploy
- Frontends: Vercel, Cloudflare Pages.
- Backends: Railway, Render, Fly.io.
- Edge functions: Cloudflare Workers, Vercel Edge.
- Long jobs: Railway workers, Render background workers.
Part II · Package
2. Containerizing with Docker
dockerfileclaude-code
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
CMD ["node", "dist/index.js"]Claude Code — Terminal
Screenshot placeholder
Terminal building a Docker image and running the container locally on port 3000.
Part III · Ship
3. Deploying to Railway
- Push your repo to GitHub.
- New project → Deploy from GitHub → pick the repo.
- Add env vars in the Variables tab.
- Attach Postgres or Redis with one click.
Part III · Ship
4. Deploying to Vercel
Best for Next.js, Vite, Astro. Every PR gets a preview URL — ship demos to clients in seconds.
Part III · Ship
5. Deploying to Render
Clean choice for long-running services, cron jobs, and static sites with a predictable pricing model.
Part III · Ship
6. Cloudflare Workers
Global edge compute with sub-50ms cold starts. Great for AI proxy layers and webhooks.
Part IV · Ops
7. Cron & Background Jobs
bashclaude-code
# Railway cron
0 9 * * * node dist/jobs/digest.js
0 * * * * node dist/jobs/refresh-index.jsPart IV · Ops
8. Secrets & Environments
- Use three environments: development, preview, production.
- Never commit .env. Rotate any leaked key within an hour.
- Prefer platform secret stores over hand-rolled ones.
Part IV · Ops
9. Observability
- Structured logs (JSON) so you can filter later.
- An "AI request log" table: prompt, model, latency, tokens, cost.
- Uptime pings and error alerts to a shared channel.
Claude Code — Terminal
Screenshot placeholder
Grafana panel plotting AI request cost per hour, split by model and endpoint.
Part V · Money
10. Managing AI Costs
- Cache prompt/response pairs when inputs are identical.
- Route "easy" tasks to smaller/cheaper models.
- Cap max tokens on every call.
- Alert when daily spend crosses a threshold.
Part V · Money
11. Scaling Basics
- Queue long jobs; do not do them in the request cycle.
- Move heavy reads behind a cache (Redis or KV).
- Paginate everything that could grow past 100 rows.
Part VI · Launch
12. Launch Checklist
- All secrets in the platform vault, not in code.
- Custom domain with HTTPS.
- Error monitoring wired up.
- Backups scheduled for the DB.
- Cost alerts on the AI provider.
- README describes how to run locally in one command.
- One human-readable status page or channel.