This project is a simple Flask app developed for helping to illustrate how to set up a deployment pipeline on GCP with Cloud Builder, Container Registry and Cloud Run.
Check the complete tutorial here.
git clone git@github.com:ivamluz/cloud-run-sample-flask.git
cd cloud-run-sample-flask
-
Install Python 3.7+
-
Create and activate an isolated Python environment
virtualenv venv source ./venv/bin/activate
-
Install the dependencies
pip install --upgrade -r requirements.txt
cd app
HASHED_API_KEY=`../scripts/hash_value.py --value "1234"` \
gunicorn --bind :8080 --workers 1 --threads 8 app:app --reload
Here, HASHED_API_KEY
is a variable used by the application to set up a basic auth mechanism. The intent of this is to show how to configure and use environment variables on Google Cloud Run.
From a different terminal instance, run the following command (notice the value for the x-api-key
is the unhashed value passed to the HASHED_API_KEY
variable in the previous command):
curl \
-H'x-api-key: 1234' \
'http://localhost:8080/hello'
Expected Output
{"hello":"world"}
If you see the output above, it means everything is working as expected.
After everything is running, please make sure to keep reading the tutorial.