Reputation: 3391
I have a single page application which I want to host in different gcp projects, i.e. different firebase projects.
The deployment should be done continuously to my firebase hosting, I want to seperate Continuous Build and Continuous Deployment steps and therefore I don't want to deploy from my local machine to all my firebase projects manually.
Is there any best practice around for deploying to a firebase hosting project when I don't want to deploy from my local machine?
In my naive way, I am going to setup the following:
I need to build a zip file that contains all the static html and js files plus my firebase.json and .firebaserc file which I upload to my storage bucket.
With those files the firebase
CLI tool is able to execute firebase deploy --only hosting:mytarget
. A google cloud builder could run this command on a git push (from github.com for example) that knows about all my gcp projects I want to deploy the single page app to...
However this is a lot of work and maybe there is a nicer solution for this. I tried to put a gs:// link directly to the firebase.json hosting/public section, however firebase CLI does not recognize this (it needs a local folder) :-(
{
"hosting": [
{
"target": "mySPAApp",
"public" : "gs://mystorage-containing-files-for-hosting/",
"rewrites": [
{
"source": "apps/myapp/**",
"destination": "myapp/index.html"
}]
}
]
}
My guts feelings say that there must be an easier way, maybe even with gcloud
CLI that just deploys a bunch of files to firebase hosting.
Internally in firebase the functionality should be implemented similarly to this, because in the firebase console the user can simply rollback to a previous version of the hosted application, however there seems to be no documentation about this.
Upvotes: 6
Views: 651
Reputation: 3391
Ok, I found out that there is an official REST API for firebase hosting which is a bit cumbersome to use. https://firebase.google.com/docs/hosting/reference/rest/v1beta1/sites.versions/create The format of the configuration is different to what is provided normally in firestore.json and the files needed to be uploaded in a state-machine manner in a Version before a Release is created.
Still, not a solution to opt for in my opinion.
Upvotes: 0