https://github.com/ivamluz/cloud-build-cloud-functions-pipeline
A sample project showing how to automate the deployment of Cloud Functions with Cloud Build on Google Cloud Platform.
https://github.com/ivamluz/cloud-build-cloud-functions-pipeline
Last synced: 4 months ago
JSON representation
A sample project showing how to automate the deployment of Cloud Functions with Cloud Build on Google Cloud Platform.
- Host: GitHub
- URL: https://github.com/ivamluz/cloud-build-cloud-functions-pipeline
- Owner: ivamluz
- License: apache-2.0
- Created: 2020-06-20T14:58:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-22T12:44:13.000Z (over 3 years ago)
- Last Synced: 2024-08-13T07:16:03.668Z (8 months ago)
- Language: Shell
- Size: 26.4 KB
- Stars: 26
- Watchers: 2
- Forks: 15
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ivamluz/cloud-build-cloud-functions-pipeline - A sample project showing how to automate the deployment of Cloud Functions with Cloud Build on Google Cloud Platform. (Shell)
README
# cloud-build-cloud-functions-pipeline
## 1. Introduction
This is a simple project developed with the intent to show:
- how to develop and debug your application locally with [functions-framework-python](https://github.com/GoogleCloudPlatform/functions-framework-python).
- how to automate the deployment of Cloud Functions with Cloud Build on Google Cloud Platform.Check the complete tutorial [here](https://medium.com/@ivam.santos/how-to-develop-debug-and-test-your-python-google-cloud-functions-on-your-local-dev-environment-d56ef94cb409).
## 2. Environment setup
### 2.1. Get the code
```bash
git clone [email protected]:ivamluz/cloud-build-cloud-functions-pipeline.git
cd cloud-build-cloud-functions-pipeline
```### 2.2. Virtualenv
- Install Python 3.7+
- Create and activate an isolated Python environment
```bash
virtualenv --python `which python3.7` venv
source ./venv/bin/activate
```- Install the dependencies
```bash
pip install --upgrade -r requirements-dev.txt
```## 3. Run and test the app locally
### 3.1 Testing the pub/sub example
From inside the `/scripts` folder:
```bash
./run-local-pubsub.sh
```From a different terminal window:
```bash
./test-local-pubsub.sh "my message"
````test-local-pubsub.sh` does the following behind the scenes:
- encodes the message passed as parameter in **base64** format;
- reads the contents of `payloads/test-local-payload.json` and replaces its `data` property with the **base64** encoded message;
- performs an HTTP post request to `http://localhost:8080` (the default address the application runs when you execute `./run-local-pubsub.sh` from the other terminal window), sending the modified JSON from the previous step in the payload.On the terminal window where you ran `./run-local-pubsub.sh` you should see some logs showing a message was received.
### 3.2 Testing the HTTP example
From inside the `/scripts` folder:
```bash
./run-local-http.sh
```From a different terminal window:
```bash
./test-local-http.sh
````test-local-http.sh` performs a `GET` HTTP request to `http://localhost:8080/?subject=FooBar` and prints the response:
```console
$ ./test-local-http.sh
Hello, FooBar!
```After everything is running, please make sure to keep reading the [tutorial](https://medium.com/@ivam.santos/how-to-develop-debug-and-test-your-python-google-cloud-functions-on-your-local-dev-environment-d56ef94cb409).