Skip to main content
Gitflare runs entirely on Cloudflare’s serverless infrastructure, making deployment simple and scalable. This guide walks you through deploying your Gitflare instance to production.
Before deploying, ensure you’ve completed the installation and configuration steps.

Pre-deployment checklist

Before deploying to production, verify these items:
1

Verify authentication

Ensure you’re logged into Wrangler:
pnpm wrangler whoami
If not authenticated, run:
pnpm wrangler login
2

Apply database migrations

Apply migrations to your production D1 database:
cd apps/web
pnpm db:migrate:remote
3

Set production secrets

Set your Better Auth secret for the production environment:
alchemy secret set BETTER_AUTH_SECRET
You’ll be prompted to enter the secret value securely.
Never commit secrets to version control. Use Alchemy’s secret management or environment variables.
4

Configure custom domain (optional)

If using a custom domain, update PROD_DOMAIN in apps/web/alchemy.run.ts:
alchemy.run.ts
const PROD_DOMAIN = "gitflare.yourdomain.com";
Then configure the domain in your Cloudflare dashboard and update DNS records to point to Cloudflare.

Deployment process

Gitflare uses Alchemy for deployment orchestration, which handles Workers, Durable Objects, and D1 database bindings automatically.
1

Build the application

Build the production bundle:
pnpm build
This compiles the TanStack Start application and prepares it for deployment.
2

Deploy to production

Deploy your application to Cloudflare Workers:
cd apps/web
pnpm deploy
Alchemy handles the deployment of:
  • Cloudflare Worker with your application code
  • Durable Objects for Git repository storage
  • D1 database bindings
  • Custom domain configuration (if configured)
The first deployment may take a few minutes as Cloudflare provisions resources.
3

Verify deployment

After deployment completes, Alchemy outputs your Worker URL. Visit this URL to verify your deployment:
https://gitflare.your-subdomain.workers.dev
Or your custom domain if configured:
https://gitflare.yourdomain.com

Deployment environments

Gitflare supports multiple deployment environments through Alchemy’s stage management.

Local development

Run the development server locally:
pnpm dev
This starts Alchemy in development mode with:
  • Hot module reloading
  • Local database bindings
  • SITE_URL set to http://localhost:3000
  • Debug logging enabled

Preview deployments

For pull requests and testing, deploy preview environments:
alchemy deploy --stage preview
Preview deployments automatically:
  • Use a unique subdomain
  • Comment on GitHub PRs with the preview URL
  • Isolate database changes

Production deployment

Deploy to production:
pnpm deploy
Production deployments:
  • Use your custom domain (if configured)
  • Set LOG_LEVEL to warn
  • Apply production secrets
  • Enable performance optimizations

Managing deployments

View deployment status

Check the status of your deployed Worker:
pnpm wrangler deployments list

Rollback deployment

If you need to rollback to a previous deployment:
pnpm wrangler rollback
Follow the prompts to select which deployment to rollback to.

View logs

Tail logs from your production Worker:
pnpm wrangler tail
This streams real-time logs from your Worker. Press Ctrl+C to stop.

Database management

Run migrations

Apply new migrations to your production database:
pnpm db:migrate:remote

Query production database

Execute queries against your production D1 database:
pnpm wrangler d1 execute DB --remote --command="SELECT * FROM users LIMIT 10"
Be careful when running queries against production. Always test migrations locally first.

Continuous deployment

For automated deployments, integrate Gitflare with your CI/CD pipeline.

GitHub Actions example

Create .github/workflows/deploy.yml:
deploy.yml
name: Deploy to Cloudflare

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - uses: pnpm/action-setup@v2
        with:
          version: 10.19.0
      
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: 'pnpm'
      
      - name: Install dependencies
        run: pnpm install
      
      - name: Build
        run: pnpm build
      
      - name: Deploy
        run: cd apps/web && pnpm deploy
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          BETTER_AUTH_SECRET: ${{ secrets.BETTER_AUTH_SECRET }}
Add CLOUDFLARE_API_TOKEN and BETTER_AUTH_SECRET to your GitHub repository secrets.

Troubleshooting

Ensure you’re logged into Wrangler:
pnpm wrangler login
Verify your authentication status:
pnpm wrangler whoami
Check that your Cloudflare credentials are set correctly in .env:
  • CLOUDFLARE_ACCOUNT_ID
  • CLOUDFLARE_DATABASE_ID
  • CLOUDFLARE_D1_TOKEN
Verify the database exists:
pnpm wrangler d1 list
Verify the domain is configured in alchemy.run.ts:
const PROD_DOMAIN = "gitflare.yourdomain.com";
Ensure DNS records point to Cloudflare and the domain is active in your Cloudflare dashboard.
Check Worker logs for errors:
pnpm wrangler tail
Common issues:
  • Missing environment variables
  • Database migration not applied
  • Durable Objects not properly bound

Monitoring and performance

Cloudflare dashboard

Monitor your deployment from the Cloudflare Workers dashboard:
  1. Navigate to Workers & Pages in your Cloudflare account
  2. Select your gitflare-web Worker
  3. View metrics including:
    • Request count
    • Error rate
    • CPU time
    • Invocations

Performance optimization

For optimal performance:
  • Enable caching for static assets
  • Use Cloudflare CDN for repository clones
  • Monitor Durable Object usage
  • Set appropriate LOG_LEVEL in production (warn or error)

Cleanup and teardown

To remove your Gitflare deployment:
cd apps/web
pnpm destroy
This permanently deletes your Worker, Durable Objects data, and associated resources. D1 databases are not automatically deleted.
To delete the D1 database:
pnpm wrangler d1 delete gitflare-db

Next steps

Development workflow

Learn about local development and testing

API reference

Explore Gitflare’s API documentation

Build docs developers (and LLMs) love