Cloud Functions is an event-driven serverless compute platform. Cloud Functions allows you to write your code without worrying about provisioning resources or scaling to handle changing requirements. This repository provide you a glimpse of
- How to deploy your backend as Cloud Functions in GCP
- Testing the cloud functions with Postman and Newman
- Automate the deploying process with Cloud Build
- Slack integration to get notification after each build
- Signup to GCP, Its nearly free for a year!
- Install the
gcloud
command line tool as per your operating system - Clone this repository
- Install the dependencies
npm i
- Run the backend locally to check everything works fine
npm start
-
if all runs well, navigate to the browser and open
http://localhost:8081/api/portfolio
. It should show the json response. -
Run unit test with command
npm run test:unit
- Stop the local service and deploy it to the GCP
gcloud beta functions deploy myWebsiteBackend --trigger-http --runtime nodejs10
-
Once the function got deployed you will receive the
endpoint
printed in the `console. Grab the endpoint -
Push this as a new repository in your own Github/any-other source code management space.
-
Create a trigger with installing github Could Build App for your repository.
-
Now go to the Cloud Build console and navigate to
Trigger
section. Create a new trigger of your choice. Just keep in mind to provide auser substitute
value with your grabbed url in earlier function deployment stage
- Now, trigger the run or push a commit to your repo. You can see the magic happening in the newly triggered build.
Find more in this Medium Article
Any suggestions/PR top rectify flows is welcome!