Skip to content

Commit

Permalink
feat: docker cache (Checkpoint)
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Burgman committed Jan 23, 2022
1 parent a0fae3d commit 84bd6cb
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ Thumbs.db
.firebase/*
.firebaserc
firebase-debug.log

npm-debug.log*
firebase-debug.log*
database-debug.log*
firestore-debug.log*
pubsub-debug.log*

# Environment
service_account.json

# Docker
/.cache
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ RUN npm install
VOLUME ["/code"]

# Install Java for the Emulators
RUN apt-get update && apt-get -y install default-jre
RUN apt-get update -y && apt-get install -y curl openjdk-11-jre-headless

# Run Project by default
CMD sh d-run.sh
4 changes: 3 additions & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ Setting up our workspace to work with Firebase is fairly straightforward. Start

> `npm install -g firebase-tools@latest`
Go ahead and also already set up your project on Firebase.
Go ahead and set up your project on Firebase if you have not.

https://console.firebase.google.com/

Create a Service Account to use for development in the Firebase console. Download the key as JSON and add to the root directory as `service_account.json`.

## Setup
Start by initializing firebase in the root directory:

Expand Down
6 changes: 4 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ services:
volumes:
- ./:/code
- /code/node_modules # Excludes node_modules
- ./.cache:/root/.cache # Cache for firebase emulators
ports:
- "9229:9229"
- "9900-9905:9900-9905"
- "9990-9905"
environment:
# Credentials URL
- GOOGLE_APPLICATION_CREDENTIALS="path/to/key.json"
- GOOGLE_APPLICATION_CREDENTIALS=/code/service_account.json
- GCLOUD_PROJECT=dereekb-components
9 changes: 9 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,31 @@
"rules": "storage.rules"
},
"emulators": {
"hosting": {
"enabled": false
},
"auth": {
"host": "0.0.0.0",
"port": 9900
},
"functions": {
"host": "0.0.0.0",
"port": 9901
},
"firestore": {
"host": "0.0.0.0",
"port": 9902
},
"pubsub": {
"host": "0.0.0.0",
"port": 9903
},
"storage": {
"host": "0.0.0.0",
"port": 9904
},
"ui": {
"host": "0.0.0.0",
"enabled": true,
"port": 9905
}
Expand Down
8 changes: 4 additions & 4 deletions firestore-debug.log
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Jan 22, 2022 3:49:53 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://localhost:36751
API endpoint: http://localhost:9000
Jan 23, 2022 12:36:47 AM com.google.cloud.datastore.emulator.firestore.websocket.WebSocketServer start
INFO: Started WebSocket server on ws://0.0.0.0:40017
API endpoint: http://0.0.0.0:9902
If you are using a library that supports the FIRESTORE_EMULATOR_HOST environment variable, run:

export FIRESTORE_EMULATOR_HOST=localhost:9000
export FIRESTORE_EMULATOR_HOST=0.0.0.0:9902

Dev App Server is now running.

5 changes: 4 additions & 1 deletion packages/demo-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { ExpressAdapter } from '@nestjs/platform-express';
import { AppModule } from './app/app.module';
import * as express from 'express';
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp();

const server = express();

Expand All @@ -22,4 +25,4 @@ createNestServer(server)

export const api = functions.https.onRequest(server);

functions.https.onCall
console.log('Test');
10 changes: 5 additions & 5 deletions pubsub-debug.log
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
This is the Google Pub/Sub fake.
Implementation may be incomplete or differ from the real system.
Jan 22, 2022 3:50:00 AM com.google.cloud.pubsub.testing.v1.Main main
Jan 23, 2022 12:36:51 AM com.google.cloud.pubsub.testing.v1.Main main
INFO: IAM integration is disabled. IAM policy methods and ACL checks are not supported
Jan 22, 2022 3:50:00 AM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
Jan 23, 2022 12:36:52 AM io.gapi.emulators.netty.NettyUtil applyJava7LongHostnameWorkaround
INFO: Applied Java 7 long hostname workaround.
Jan 22, 2022 3:50:00 AM com.google.cloud.pubsub.testing.v1.Main main
INFO: Server started, listening on 8085
Jan 22, 2022 3:50:00 AM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
Jan 23, 2022 12:36:52 AM com.google.cloud.pubsub.testing.v1.Main main
INFO: Server started, listening on 9903
Jan 23, 2022 12:36:52 AM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
INFO: Adding handler(s) to newly registered Channel.
2 changes: 1 addition & 1 deletion ui-debug.log
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Web / API server started at localhost:4000
Web / API server started at 0.0.0.0:9905
3 changes: 0 additions & 3 deletions workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@
"commands": [
{
"command": "nx run-emulators demo-api"
},
{
"command": "nx serve-api demo-api"
}
],
"parallel": true
Expand Down

0 comments on commit 84bd6cb

Please sign in to comment.