Skip to content

Deployment Guide

Deploy your boilerplate to production.

Quick Start

Bash
1
2
3
4
5
# See deployment options
task deployment:options

# Deploy to Railway (recommended)
task deployment:railway-docker

Deployment Options

Single Docker deployment - simplest option.

Pros:

  • One-click deployment
  • Automatic HTTPS
  • Built-in PostgreSQL
  • Git push to deploy
  • $5/month starter

Setup:

  1. Create Railway account
  2. New Project → Deploy from GitHub
  3. Add PostgreSQL service
  4. Set environment variables
  5. Deploy

Railway guide

Vercel + Railway

Frontend on Vercel, Backend on Railway - scalable option.

Pros:

  • Vercel CDN for frontend
  • Railway for backend/database
  • Best performance
  • ~$10/month

Setup:

  1. Deploy frontend to Vercel
  2. Deploy backend to Railway
  3. Configure CORS for Vercel URL

Digital Ocean

App Platform - managed deployment.

Pros:

  • Managed PostgreSQL
  • Automatic builds
  • Monitoring included
  • ~$12/month

Setup:

  1. Create DO account
  2. New App → GitHub repo
  3. Add managed PostgreSQL
  4. Set environment variables
  5. Deploy

Docker (Self-Hosted)

Own VPS - full control.

Build:

Bash
docker build -t your-app .
docker run -p 8020:8020 your-app

Pros:

  • Full control
  • Cheapest option
  • Any provider

Cons:

  • Manual setup
  • You manage everything

Environment Variables

Required (All Deployments)

Text Only
# Environment
env=production

# Database
db_host=your-production-db-host
db_port=5432
db_database=craftyourstartup_prod
db_username=prod_user
db_password=SECURE_PASSWORD
db_sslmode=require

# Security
secret_key=GENERATE_SECURE_32_CHAR_STRING
algorithm=HS256
access_token_expire_minutes=30

# Application
domain=https://yourdomain.com
redirect_after_login=https://yourdomain.com/dashboard

Top G+ (Payment Features)

Text Only
# Stripe (LIVE keys)
STRIPE_SECRET_KEY=sk_live_...
STRIPE_PUBLISHABLE_KEY=pk_live_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Product prices
STRIPE_PRICE_STARTER=price_live_...
STRIPE_PRICE_PRO=price_live_...
STRIPE_PRICE_PREMIUM_SUB=price_live_...
STRIPE_PRICE_ENTERPRISE_SUB=price_live_...

# Email
mailchimp_api_key=your_production_key
[email protected]
from_name=Your Company
[email protected]

Optional

Text Only
1
2
3
4
# Google OAuth
google_oauth2_client_id=your-prod-id
google_oauth2_secret=your-prod-secret
google_oauth2_redirect_uri=https://yourdomain.com/api/auth/google_callback

Database Setup

Apply Migrations

From local machine:

Bash
1
2
3
# Configure prod.env with production database
# Then apply migrations
task db:migrate-up-prod

In deployment platform:

Bash
1
2
3
# Railway/DO will run migrations on deploy
# Or add to Dockerfile:
CMD alembic upgrade head && uvicorn main:app --host 0.0.0.0 --port 8020

Create Superuser (Top G+)

Bash
# SSH into production or use platform CLI
poetry run python app/commands/create_superuser.py

Stripe Webhook Setup (Top G+)

Production Webhook

  1. Go to Stripe Dashboard
  2. Add endpoint: https://yourdomain.com/api/payments/webhook
  3. Select events:
  4. checkout.session.completed
  5. customer.subscription.created
  6. customer.subscription.updated
  7. customer.subscription.deleted
  8. invoice.payment_succeeded
  9. invoice.payment_failed
  10. Copy webhook secret to environment variables

SSL/HTTPS

All platforms provide automatic HTTPS: - Railway: Automatic - Vercel: Automatic
- Digital Ocean: Automatic

Custom domain: Configure DNS to point to platform.

Monitoring

Health Check:

Bash
curl https://yourdomain.com/api/health
# Should return: {"status":"healthy"}

Logs:

  • Railway: Dashboard → Logs
  • Vercel: Dashboard → Functions → Logs
  • Digital Ocean: Dashboard → Runtime Logs

Scaling

Railway: Automatic scaling
Vercel: Automatic scaling (frontend)
Digital Ocean: Manual scaling (resize droplet)

Security Checklist

  • Use HTTPS (automatic on platforms)
  • Strong secret_key (32+ characters)
  • Live Stripe keys (not test)
  • Secure database password
  • Environment variables (not hardcoded)
  • CORS configured for production domain
  • Webhook secrets verified

Cost Estimates

Hobby/Starter:

  • Railway: $5-10/month
  • Vercel Free + Railway DB: $5/month
  • Digital Ocean: $12/month

Production:

  • Railway Pro: $20+/month
  • Vercel Pro + Railway: $20+/month
  • Digital Ocean: $24+/month