This project demonstrates the ability to deploy an application to Control Plane that utilizes:
- Firebase Authentication
- Firestore
- reCAPTCHA v3
- Existing Control Plane Org and GVC.
- Control Plane CLI: https://docs.controlplane.com/reference/cli
- Firebase Account: https://firebase.google.com/
- Clone current repository.
- Follow Step 1 in this guide to create a Firebase project and register your app:
- Using the
firebaseConfig
from the registration step, update theinitializeApp
method in the file./src/app/firebase.js
. - To configure Firebase authentication using Google:
- Click
Authentication
in the left menu. - Click the
Get started
button. - Click the
Google
button. - Toggle the
Enable
button. Enter a project name and email (if required). ClickSave
.
- Click
- To configure a new Firestore database:
- Click
Firestore Database
in the left menu. - Click the
Create Database
button. - Select
Start in test mode
and clickNext
. - Select a location and click
Enable
. It will take a few minutes to create. - Select
Rules
at the top menu and update the rule with the following and clickPublish
:rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /messages/{message} { allow read: if request.auth.uid != null; allow write: if request.auth.uid != null; } } }
- Click
- To configure reCAPTCHA v3:
- Browse to: https://www.google.com/recaptcha/admin
- The
Register a new site
page will be displayed or click the+
button. - Enter the following:
- Any name for the
Label
. - Select
reCAPTCHA v3
. - Enter
example.com
temporarily for theDomains
. We'll add the real domain after creating the workload. - Accept the
Terms of Service
andSend alerts..
and clickSubmit
. - Save the
Site Key
andSecret Key
.
- Any name for the
- Update the
active
method on Line 19 with theSite Key
. - Return to the Firebase console for the project and select the gear icon to the right of the
Project Overview
and clickProject settings
. - Select
App Check
on the top menu bar. - Click the name of your
Web App
, clickreCAPTCHA
, enter theSecret Key
and clickSave
.
- To deploy to Control Plane:
- If necessary, authenticate using:
cpln login
. - Containerize the application and push the image to the org's private image repository using the command (substitute ORG_NAME with the target Org):
cpln image build --name firebase-demo:1 --push --org ORG_NAME
- Create a workload using the command (substitute ORG_NAME with the target Org and GVC_NAME with the target GVC):
cpln workload create --name firebase-demo --image //image/firebase-demo:1 --public --gvc GVC_NAME
- Take note of the
ENDPOINT
URL.
- If necessary, authenticate using:
- Using the endpoint URL, the Firebase authentication's authorized domains must be updated.
- Return to the Firebase console and click
Authentication
in the left menu. - Select
Sign-in method
from the top menu. - Click
Add domain
. Enter the endpoint URL and clickAdd
.
- Return to the Firebase console and click
- Using the endpoint URL, the reCAPTCHA v3 domain must be updated.
- Return to: https://www.google.com/recaptcha/admin
- Click the gear icon.
- In the
Domains
section, to the right of the+
, enter the endpoint URL and press enter. - Delete the
example.com
by clicking theX
to the left of that domain. - Scroll to the bottom and click
Save
.
The application has now been fully configured and ready to serve traffic.
- Browse to the endpoint URL and the application will be displayed.
- Click the
Sign In
button to log in using your Google credentials. - Once logged in, you can enter a chat message. Those messages are persisted using Firestore and are pushed to other users logged into the chat application.
- The header displays your name and the cloud provider that served the request.