Firebase Emulators easy start with backup and restore

Use this docker-compose setup to easily run your firebase suite locally with saved data

Fri, 05 Jan 2024

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

Buy Me A CoffeeDigitalOcean Referral Badge
Loading...
Edward Beazer

Edward Beazer - I just like to build shit. Sometimes I get stuck for hours, even days while trying to figure out how to solve an issue or implement a new feature. Hope my tips and tutorials can save you some time.

DigitalOcean Referral Badge