Skip to content

Latest commit

 

History

History

gcloud-firebase

Deploy Fiber to Google Cloud with Firebase

Examples on how to run an application using Fiber on Google Cloud and connecting to Firebase Realtime Database.

Running Locally

  • Run on the command line:
go run cmd/main.go

Deploy using Google Cloud Run

This step will build a Docker Image, publish to Google Cloud Registry and deploy on Cloud Run Managed enviroment.

Just follow the steps and fill the GCP_PROJECT variable with your Google Cloud Platform project ID. That variable is needed to connect to Firebase.

Run on Google Cloud

After deploying the server on Cloud Run, you can get it's url on GCP Console (link) and select the service gcloud-fiber-firebase that we just deployed. Then copy the URL. It will look like https://{project-id}-{some-random-hash-string}.a.run.app.

Or you can do it manually with those steps:

  • Run on the command line:
export GCLOUD_PROJECT=[YOUR_PROJECT_ID]
gcloud builds submit — -tag gcr.io/$GCLOUD_PROJECT/gcloud-fiber-firebase .
gcloud beta run deploy --platform managed --image gcr.io/$GCLOUD_PROJECT/gcloud-fiber-firebase \
 --set-env-vars GCP_PROJECT=$GCLOUD_PROJECT

Deploy using Google App Engine

This step will deploy the app to Google App Engine Standard Go enviroment. The app configuration and additional configurations can be tweaked on the app.yaml file.

  • Run on the command line:
gcloud app deploy

Deploy using Google Cloud Function

This step will deploy a HTTP Cloud Function using Go enviroment. You can use the deploy.sh script. Just edit your project id on it.

For the Cloud Functions env, Google enforces us to deploy a function that is a http.HandlerFunc, so on the file functions.go there is a workaround to reroute the HTTP call to the Fiber app instance.

  • Run on the command line:
gcloud functions deploy HeroesAPI --runtime go111 --trigger-http