Welcome to our tutorial where you'll learn how to deploy a simple Python web application using Docker and Google Cloud Run. We'll utilize Terraform for infrastructure orchestration.
Ensure you have the following installed:
- Git (version 2.39 or higher)
- Docker (version 27.0 or higher)
- gcloud CLI
- Terraform (version 1.6 or higher)
For manual provisioning via the console, please see the references section at the end of this document.
Clone the repository to get the required files:
git clone [email protected]:Google-Developer-Groups-Siliguri/GDG-SILIGURI-X-GCCD-Extended-Event.gitCreate a Google Cloud account and login to the console. Once logged in, create a new project.
Update the project ID in the Makefile and terraform/terraform.tfvars files. Replace the placeholder with your own project ID.
Build and push the Docker image to your Google Container Registry:
make docker-pushYou will be redirected to your browser to authenticate. Complete the authentication process, and this will build and push your Docker image to GCR.
Navigate to the terraform directory and run the following command:
terraform applyYou will be prompted with the planned changes. Type yes and press Enter to continue. After some time, you will receive a successful response along with the public URL of your application as output.
In this step, we are creating a Cloud Run service that will run this application in a container, granting public access to your service.
Visit the provided URL to see your application in action. You can also test its functionality using curl:
curl -X POST -H "Content-Type: application/json" \
-d '{"num1": 10, "num2": 50}' \
https://[YOUR_CLOUD_RUN_URL]/add
{"result":60}For those interested in manual provisioning via the Google Cloud Console, please refer to Google Cloud Documentation.