Use .gcloudignore to Ignore files deploy to the Cloud Functions

2022/10/021 min read
bookmark this
Responsive image

About .gcloudignore file

When you deploy Node.js code to the google cloud functions, you can run the code from your local environment by run below command.

So this command will deploy the current folder's entire source code to the cloud function, by default will also create a .gcloudignore file and you'll notice the file itself and node_modules are also in the file, so that way these files won't be deploy to the cloud.

gcloud functions deploy my-first-function --trigger-http --region=us-central1 --runtime=nodejs16 --gen2 --allow-unauthenticated --entry-point=main

So if you want to ignore other files, you can add these to the .gcloudignore as well, for instance, file if you have any.