157 words
1 minute
Firebase Emulators easy start with backup and restore
This one is going to be quick and easy. Firebase has emulators that let you simulate a firebase environment locally. These emulators run in docker containers. This config will give you a docker container with the emulators installed and expose all the ports that you need to have exposed.
Add these files to the root of you project
Dockerfile
FROM node:lts
VOLUME ["/firebase"]
WORKDIR /firebase
RUN apt-get update
RUN apt-get -y install default-jre
RUN npm install -g firebase-tools
ENV GOOGLE_APPLICATION_CREDENTIALS=/firebase/google_creds.json
ENTRYPOINT ["firebase", "emulators:start", "--import=/firebase/emulator-data", "--export-on-exit"]
docker-compose.yaml
version: "3.9"
services:
firebase_emulators:
build: "."
restart: always
volumes:
- .:/firebase
ports:
- "8080:8080"
- "9099:9099"
- "5001:5001"
- "9199:9199"
- "4500:4500"
- "4400:4400"
- "4000:4000"
- "9299:9299"
- "5000:5000"
- "8085:8085"
One thing to note, you do need your Google credentials file which you can get from the firebase console.
To run your emulators, docker-compose up
. When you want to save the data, docker-compose down
. Do note, the data will be saved in a folder named emulator-data
Firebase Emulators easy start with backup and restore
https://edwardbeazer.com/posts/firebase-emulators-easy-start-with-backup-and-restore/