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