Install the Java version used by the Firebase Local Emulator in the Firebase builder image
korneel opened this issue · comments
Affected builder image
firebase (https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/firebase)
Expected Behavior
Being able to run tests using the Firebase Local Emulator by running the command firebase emulators:exec --only=firestore ./test.sh
.
Actual Behavior
The Firebase Local Emulator can't be started because Java is not available: Firestore Emulator has exited because java is not installed, you can install it from https://openjdk.java.net/install/
Steps to Reproduce the Problem
-
Build and push the Firebase community builder image to a Google Cloud project as described here.
-
Create a cloudbuild.yaml file:
steps:
- name: 'gcr.io/$PROJECT_ID/firebase'
args: ['emulators:exec', '--only=firestore', './test.sh']
- Create a test.sh file:
#!/bin/sh
echo "Hello, world! The time is $(date)."
- Start the build:
gcloud builds submit --config cloudbuild.yaml .
Additional Info
The Java version used by the Firebase Local Emulator should be installed in the Firebase builder image.
As a workaround, the Firebase Local Emulator can be used if you change FROM node
to FROM timbru31/java-node
in de Dockerfile of the Firebase community builder image before building and pushing it to your Google Cloud project's Container Registry.
I found some packaging I'd done for this in Aug 2020 and turned it to support Cloud Registry. https://github.com/akauppi/firebase-custom-builder
There's also a super-charged version of the Firebase emulators suite available here: https://github.com/SpineEventEngine/gcp-emulators/tree/master/firebase-emulator