In this project, I built a containerized service and set up a CI/CD workflow to automatically deploy to Cloud Run on Google Cloud Platform.
Demo Link: https://cloud.tinchun.top/
Demo Videos:
We can deploy this project to a Kubernetes cluster with:
kubectl apply -f https://raw.githubusercontent.com/motianjun4/fastapi/master/kubernetes-deployment.yaml
# or clone the repository
kubectl apply -f ./kubernetes-deployment.yaml
In this project, I used Terraform to automatically deploy my CI/CD workflow and service to GCP.
This includes two steps:
- Create a Cloud Build trigger for CI/CD
- Create a Cloud Run resource to deploy this service.
Check main.tf for more details.
To deploy this project to GCP, simply:
- Clone this repository to the Cloud Shell,
- Modify the terraform.tfvars file,
- Use
terraform init
andterraform apply
to deploy it.
If you want to deploy this project, just:
docker pull ghcr.io/motianjun4/fastapi:master
docker run -p 8000:8000 ghcr.io/motianjun4/fastapi:master
then you can visit http://localhost:8000/
You can setup the development environment on docker or on local machine.
- Python 3
$ git clone https://github.com/motianjun4/fastapi.git
$ cd fastapi
# Optional: set up Python Virtual Environment
# Install dependencies
$ make install
# Run Development Server
$ make run