Home > Back-end >  Is there a way to deploy Cloud Functions directly as zip artifacts to Google Cloud Platform? and not
Is there a way to deploy Cloud Functions directly as zip artifacts to Google Cloud Platform? and not

Time:12-03

The default setup for firebase functions is to run firebase deploy, which will:

  • Upload the whole project to Cloud Build
  • Cloud Build will extract the functions
  • It will run npm install.
  • Create the ZIP artefacts
  • Upload the ZIP artefacts to the cloud

The question is if you know of a way to make these ZIP artefacts on our side and upload them directly?

Default Cloud Build steps List of the Cloud Build deployments

CodePudding user response:

From my point of view - there are plenty of options how to deploy one or more cloud functions.

The Deploying Cloud Functions documentation provides some initial context.

The easiest way, from my point of view, to use gcloud functions deploy command - see Cloud SDK CLI - gcloud functions deploy

As a side note - from my personal point of view - an idea to use Cloud Build - is not bad, and it has many benefits (security, organization of CI/CD, etc.) but it is up to you. Personally I use Cloud Build with Terraform, and configured deployment in a such a way, that only updated Cloud Functions are redeployed.

CodePudding user response:

There is different "level" of cloud build to take into consideration.

If it's the first step, I mean create a ZIP with the code of your function, no problem, you can do it on your side. Then you can deploy the zip through the console or with api calls

In both case, you need a zip and you deploy it. And, if you use the gcloud functions deploy command, it do exactly the same thing: create a zip, send it to storage and deploy the function from that ZIP!


That's was for the first stage, where you manage the ZIP creation and sending on the cloud.

HOWEVER, to deploy the ZIP code to Google Cloud Platform you need to package that code in a runnable stuff, because you only have a function and a function isn't runnable and can't handle HTTP request.

Therefore, Google Cloud run a Cloud Build under the hood and use Buildpacks to package your code in a container (yes, all is container at Google Cloud), and deploy that container on the Cloud Functions platform.

You can't discard that container creation, without container your Cloud Functions can't run. Or you can use Cloud Run and build your own container on your side and deploy it without Cloud Build.

  • Related