diff --git a/.gitignore b/.gitignore index 8b11fe200..0a9ba9213 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/Dockerfile b/Dockerfile index 7b56103af..d44fde6d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/NOTES.md b/NOTES.md index 7a09eb844..22bb80642 100644 --- a/NOTES.md +++ b/NOTES.md @@ -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: diff --git a/docker-compose.yml b/docker-compose.yml index fb446f811..ea01688f3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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 diff --git a/firebase.json b/firebase.json index 90da5651c..35b71e8b9 100644 --- a/firebase.json +++ b/firebase.json @@ -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 } diff --git a/firestore-debug.log b/firestore-debug.log index 3bb6cd315..edef0a526 100644 --- a/firestore-debug.log +++ b/firestore-debug.log @@ -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. diff --git a/packages/demo-api/src/main.ts b/packages/demo-api/src/main.ts index 27bf21770..bf23d6643 100644 --- a/packages/demo-api/src/main.ts +++ b/packages/demo-api/src/main.ts @@ -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(); @@ -22,4 +25,4 @@ createNestServer(server) export const api = functions.https.onRequest(server); -functions.https.onCall \ No newline at end of file +console.log('Test'); diff --git a/pubsub-debug.log b/pubsub-debug.log index 1aadc7904..696078914 100644 --- a/pubsub-debug.log +++ b/pubsub-debug.log @@ -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. diff --git a/ui-debug.log b/ui-debug.log index 002c542d9..6b2d60f12 100644 --- a/ui-debug.log +++ b/ui-debug.log @@ -1 +1 @@ -Web / API server started at localhost:4000 +Web / API server started at 0.0.0.0:9905 diff --git a/workspace.json b/workspace.json index b3fab6371..bc47c0726 100644 --- a/workspace.json +++ b/workspace.json @@ -253,9 +253,6 @@ "commands": [ { "command": "nx run-emulators demo-api" - }, - { - "command": "nx serve-api demo-api" } ], "parallel": true