This project allows to plug in Google Cloud Firestore into Corvid by Wix site and use it as a Corvid collection database. It is implemented as NodeJS server that can be deployed either to Google Cloud Run or AppEngine. After Connector is deployed it can be used as Corvid External Database.
This project assumes you have Google Cloud Project with billing enabled. If you don't have one please follow this free trial guide.
Go to https://console.cloud.google.com/firestore/welcome and select Native Mode
Follow instructions on the Google Cloud Run quickstart guide. In the form of creating service,
- Use gcr.io/corvid-api/firestore-connector-node as a container image.
- Select Cloud Run (fully managed) as your development platform.
- Select us-east1 region.
- Select Allow unauthenticated invocations to be able to access the connector from Corvid
- Add Environment variable with name of "SECRET_KEY" and put your secret key as a value. This value will be used for connecting Corvid site.
- Click Create to deploy the image to Cloud Run and wait for the deployment to finish.
Click the displayed URL link to test the deployed connector. In the browser you should see
{"message":"Missing request context"}
This means that connector is running! Copy the service URL, this is the URL for connecting Firestore to Corvid site
-
Install the Google Cloud SDK for your operating system;
-
Acquire local credentials;
gcloud auth application-default login
-
Set project you have created as default by running
gcloud config set project PROJECTID
-
Deploy the Corvid connector container
gcloud run deploy --image gcr.io/corvid-api/firestore-connector-node --platform managed --region us-east1 --set-env-vars SECRET_KEY=[YOUR SECRET KEY]
-
Answer y when prompted "Allow unauthenticated invocations to [firestore-connector-node] (y/N)?"
-
After deployment is successful, you should see in the command output something like:
Service [firestore-connector-node] revision [firestore-connector-node-00001-nep] has been deployed and is serving 100 percent of traffic at https://firestore-connector-node-[autogenerated].run.app
-
Copy the service URL, this is the URL for connecting Firestore to Corvid site
-
-
Check out the source code
git clone https://github.com/wix-private/firestore-connector-node.git cd firestore-connector-node
-
Run deployment command in your connector project folder.
gcloud app deploy
-
After deployment, access your service at
https://<project id>.appspot.com/
Follow instructions here. In the connection Dialog settings put:
- The connector service URL from steps above in the "Add an endpoint URL" field
- {"secretKey":"Your Secret Key from the deployment step"} in the Configuration field You should see Firestore collections in the Databases sections of your site.
-
Check out the source code
git clone https://github.com/wix-private/firestore-connector-node.git cd firestore-connector-node
-
Create a GCP Service account
gcloud iam service-accounts create corvid --description Corvid Dev account --display-name corvid-dev
and copy its full name from output of
gcloud iam service-accounts list
-
Generate the Service Account key and save it in gcp-sa-key.json
gcloud iam service-accounts keys create gcp-sa-key.json --iam-account [SERVICE ACCOUNT FULL NAME]
-
Set environment variable for GCP client libraries
export GOOGLE_APPLICATION_CREDENTIALS=$PWD/gcp-sa-key.json
-
The Connector is NodeJS express application, start it with
npm install npm start