Firebase Functions Deployment Guide - Dev vs Prod โ
Last Updated: 2026-01-12
Overview โ
The Lantern app uses two separate Firebase projects:
- lantern-app-dev: Development/testing environment
- lantern-app-prod: Production environment for live users
This guide explains how to deploy and configure Firebase Cloud Functions for the feature request system to both environments.
Why It Matters โ
Critical Considerations โ
GitHub Issues: Both dev and prod functions will create issues in the same GitHub repository (
cattreedev/lantern_app)- โ ๏ธ This means dev submissions will create real GitHub issues
- We need to distinguish dev vs prod submissions with labels
Discord Notifications: You likely want separate Discord channels for dev vs prod
- Dev submissions โ #dev-feedback channel
- Prod submissions โ #user-feedback channel
Firestore Data: Each project has its own Firestore database
- Dev submissions stored in lantern-app-dev Firestore
- Prod submissions stored in lantern-app-prod Firestore
Rate Limiting: Separate per project
- User can submit 5 times in dev AND 5 times in prod (independent limits)
Project Selection โ
Check Current Target โ
# See which project is currently active
firebase projects:listSwitch Projects โ
The .firebaserc file controls the default project (currently set to lantern-app-dev).
To switch projects:
# Method 1: Use firebase use command (RECOMMENDED)
firebase use lantern-app-dev # Switch to dev
firebase use lantern-app-prod # Switch to prod
# Method 2: Use --project flag (for one-off commands)
firebase deploy --only functions --project lantern-app-prodConfiguration Strategy (RECOMMENDED) โ
Use environment-aware labels to distinguish dev vs prod submissions in the same GitHub repo.
Update Cloud Function โ
The function automatically detects which Firebase project it's running in and adds the appropriate label:
// Already implemented in functions/index.js
const projectId = process.env.GCLOUD_PROJECT
const isProduction = projectId === 'lantern-app-prod'
const envLabel = isProduction ? 'env-production' : 'env-development'
const labels = [
type === 'feature' ? 'feature-request' : type,
`priority-${priority}`,
'user-submitted',
'needs-triage',
envLabel // Automatically added!
]Separate Discord Channels โ
Configure different Discord webhooks per environment:
Development:
firebase use lantern-app-dev
firebase functions:config:set \
github.token="ghp_YOUR_TOKEN" \
github.repo="cattreedev/lantern_app" \
discord.webhook_url="https://discord.com/api/webhooks/DEV_CHANNEL/..."Production:
firebase use lantern-app-prod
firebase functions:config:set \
github.token="ghp_YOUR_TOKEN" \
github.repo="cattreedev/lantern_app" \
discord.webhook_url="https://discord.com/api/webhooks/PROD_CHANNEL/..."Deployment Workflow โ
Initial Setup โ
1. Configure Development โ
firebase use lantern-app-dev
firebase functions:config:set \
github.token="ghp_YOUR_GITHUB_TOKEN" \
github.repo="cattreedev/lantern_app" \
discord.webhook_url="https://discord.com/api/webhooks/DEV/..."
firebase deploy --only functions
firebase functions:list # Verify deployment2. Configure Production โ
firebase use lantern-app-prod
firebase functions:config:set \
github.token="ghp_YOUR_GITHUB_TOKEN" \
github.repo="cattreedev/lantern_app" \
discord.webhook_url="https://discord.com/api/webhooks/PROD/..."
firebase deploy --only functions
firebase functions:list # Verify deploymentOngoing Deployments โ
# Deploy to dev
firebase use lantern-app-dev
firebase deploy --only functions
# Deploy to prod
firebase use lantern-app-prod
firebase deploy --only functionsClient-Side Configuration โ
The client automatically uses the correct Firebase project based on environment variables:
- Local dev: Uses
.env.local(points to lantern-app-dev) - Dev deployment: Uses
.env.development(lantern-app-dev) - Prod deployment: Uses
.env.production(lantern-app-prod)
No code changes needed - Vite and Cloudflare Pages handle this automatically!
Testing โ
Local Testing (Dev Project) โ
npm run dev
# Navigate to http://localhost:5173/#/feedback
# Submit test request โ Creates issue with `env-development` labelDev Deployment โ
# Visit https://dev.ourlantern.app/#/feedback
# Submit test โ Uses lantern-app-dev + dev Discord channelProduction โ
# Visit https://ourlantern.app/#/feedback
# Submit test โ Uses lantern-app-prod + prod Discord channelBest Practices โ
โ Do โ
- Always verify active project before deploying:
firebase use - Use separate Discord webhooks for dev/prod
- Test in dev first before deploying to prod
- Keep .firebaserc defaulted to dev to prevent accidental prod deploys
โ Don't โ
- Don't deploy to prod without testing in dev
- Don't use the same Discord webhook for both environments
- Don't commit tokens/webhooks to git
Quick Reference โ
# Check active project
firebase use
# Switch projects
firebase use lantern-app-dev
firebase use lantern-app-prod
# Deploy functions
firebase deploy --only functions
# View config
firebase functions:config:get
# View logs
firebase functions:log