Sample repository showing how to integrate Doppler with Firebase.
- Doppler CLI
- Node 16
Create the yodaspeak-firebase
project in Doppler:
Or from a terminal in the root application directory, run:
doppler import
Then install the application dependencies:
npm install
This repository syncs Doppler secrets to Firebase's environment variables store by running the command:
npm run secrets-sync
Doppler is awesome because secrets are dynamically kept in sync during local development without using insecure and manually maintained .env
or .runtimeconfig.json
files.
The serve
and shell
commands use the Doppler CLI to provide secrets with the CLOUD_RUNTIME_CONFIG
environment variable. The format required for local development can be seen by running:
npm run secrets --silent | jq '{doppler: .}'
Secrets are then accessed from the functions.config().doppler
property:
const functions = require('firebase-functions')
const secrets = functions.config().doppler
By using Doppler, you and your teammates will never have out of date secrets again. This makes onboarding new engineers a breeze, plus you don't have to worry about leaking credentials in unprotected text files.
Open a terminal and change into the functions
directory, then configure the Doppler CLI for local development by running:
doppler setup
Start the Firebase functions emulator by running:
npm run serve
Then test the translation endpoint.
To launch the Firebase shell, run:
npm run shell
Deploying to production is a two-step process:
- Update your function environment variables
- Update your function code
Your CI/CD environment will need a Doppler Service Token injected as the DOPPLER_TOKEN
environment variable to provide read-only access to the Production
config.
To deploy your Firebase function with the latest environment secrets from Doppler, simply run:
npm run deploy
Check out the deploy GitHub Action for a full working example.
You can then test production by viewing the index page, secrets, or translation endpoint.