Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
skibz committed Jan 26, 2021
0 parents commit db5ebcb
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

.editorconfig
.gitignore
LICENSE.md
Makefile
README.md
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*Makefile,*.mk}]
indent_style = tab
indent_size = 4
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.DS_Store
10 changes: 10 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

MIT License

Copyright (c) 2021-present IO Digital Pty Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

.PHONY: build
build:
docker build -t ghcr.io/io-digital/firebase-emulator-suite src

.PHONY: push
push:
docker push ghcr.io/io-digital/firebase-emulator-suite
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

# firebase-emulator-suite

## usage

start by generating a CI token with `firebase login:ci` and keep this aside for later.

ensure you've got a `firebase.json` file for instructing the emulator suite which emulators to use.

example `firebase.json`:
```json
{
"emulators": {
"firestore": {
"enabled": true,
"port": "8080",
"host": "0.0.0.0"
},
"ui": {
"enabled": true,
"port": "4000",
"host": "0.0.0.0"
},
"auth": {
"enabled": true,
"port": "9099",
"host": "0.0.0.0"
}
}
}
```

link everything together in a `docker-compose.yml`:

```yaml
firebase:
image: ghcr.io/io-digital/firebase-emulator-suite
environment:
- FIREBASE_TOKEN=YOUR_FIREBASE_CI_TOKEN
- FIREBASE_PROJECT=YOUR_FIREBASE_PROJECT_NAME
volumes:
- ./path/to/keep/cached/firebase/emulators:/home/firebase/.cache/
- ./path/to/your/firebase.json:/home/firebase/firebase.json
ports:
- '9099:9099'
- '4000:4000'
- '5001:5001'
- '9000:9000'
- '8080:8080'
- '8085:8085'
- '5000:5000'
```
take note of:
* the port mappings, which have to match your assigned ports in `firebase.json`
* the volume mappings, paying special attention to:
+ volume `/home/firebase/.cache` will prevent re-downloading of individual firebase emulators every time the container is restarted
+ volume `/home/firebase/firebase.json` will not only configure **which** emulators run, but also configure the host/container networking as long as each emulator host is set to `0.0.0.0`
* the environment variables, which include your firebase token generated earlier with `firebase login:ci`§

with all of the above in place, bring up the system as normal.

you will notice on the first build/run that the firebase-emulator-suite will not respond for a while. this is normal, it is downloading the emulators.

eventually, it will print to stdout indicating that the emulators are live along with a link for opening the emulator control-plane in your browser.

this download step will only occur once, provided the cache volume was not invalidated or more emulators were configured in `firebase.json` to be run that have not yet been downloaded.
18 changes: 18 additions & 0 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine

LABEL org.opencontainers.image.source=https://github.com/io-digital/firebase-emulator-suite

RUN apk --no-cache --update add \
ca-certificates \
openjdk8-jre \
nodejs \
npm

RUN adduser -S firebase -G wheel
USER firebase
WORKDIR /home/firebase
RUN npm install firebase-tools
COPY ./start.sh ./

ENTRYPOINT ["/home/firebase/start.sh"]
6 changes: 6 additions & 0 deletions src/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

npx firebase \
--project $FIREBASE_PROJECT \
--token $FIREBASE_TOKEN \
emulators:start

0 comments on commit db5ebcb

Please sign in to comment.