Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Set up Firebase Hosting in front of a Cloud Run service
# Set up Firebase Hosting in front of a Cloud Run service, without using the firebase CLI
# The following commands must be installed:
# - gcloud
# - curl
# - jq
# Update these variables
PROJECT_ID="enable-fb-hosting" # Make sure you have enabled Firebase on this Google Cloud project
ACCESS_TOKEN=$(gcloud auth print-access-token) #Make sure you are logged into gcloud
# Inspired by
echo "Creating new Firebase Hosting version:"
curl --silent -H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"config": {
"rewrites": [{
"glob": "**",
"run": {
"serviceId": "'$CLOUD_RUN_SERVICE_NAME'",
}' \$PROJECT_ID/versions \
| jq -r '.name')
echo "New version created: $version"
echo "Finalizing..."
curl --silent -H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{"status": "FINALIZED"}' \$version?update_mask=status \
| jq '.status'
echo "Releasing..."
curl --silent -H "Authorization: Bearer $ACCESS_TOKEN" \
-X POST$PROJECT_ID/releases?versionName=$version \
| jq '.version.status'
echo "Cloud Run service $CLOUD_RUN_SERVICE_NAME ($CLOUD_RUN_SERVICE_REGION) is serving behing Firebase Hosting at https://$"
echo "Set up a custom domain at$PROJECT_ID/hosting/sites"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment