Skip to content

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

  1. 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
  2. Discord Notifications: You likely want separate Discord channels for dev vs prod

    • Dev submissions → #dev-feedback channel
    • Prod submissions → #user-feedback channel
  3. 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
  4. Rate Limiting: Separate per project

    • User can submit 5 times in dev AND 5 times in prod (independent limits)

Project Selection

Check Current Target

bash
# See which project is currently active
firebase projects:list

Switch Projects

The .firebaserc file controls the default project (currently set to lantern-app-dev).

To switch projects:

bash
# 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-prod

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:

javascript
// 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:

bash
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:

bash
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

bash
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 deployment

2. Configure Production

bash
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 deployment

Ongoing Deployments

bash
# Deploy to dev
firebase use lantern-app-dev
firebase deploy --only functions

# Deploy to prod
firebase use lantern-app-prod
firebase deploy --only functions

Client-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)

bash
npm run dev
# Navigate to http://localhost:5173/#/feedback
# Submit test request → Creates issue with `env-development` label

Dev Deployment

bash
# Visit https://dev.ourlantern.app/#/feedback
# Submit test → Uses lantern-app-dev + dev Discord channel

Production

bash
# Visit https://ourlantern.app/#/feedback
# Submit test → Uses lantern-app-prod + prod Discord channel

Best Practices

✅ Do

  1. Always verify active project before deploying: firebase use
  2. Use separate Discord webhooks for dev/prod
  3. Test in dev first before deploying to prod
  4. Keep .firebaserc defaulted to dev to prevent accidental prod deploys

❌ Don't

  1. Don't deploy to prod without testing in dev
  2. Don't use the same Discord webhook for both environments
  3. Don't commit tokens/webhooks to git

Quick Reference

bash
# 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

Built with VitePress