Example Python FastAPI application to use as a template.
Can be productionised on any compute that allows containers.
Click "Open in Cloud Shell" for a tutorial on how to get started with FastAPI
Once in the cloud shell, run the command: teachme tutorial.md
if it doesn't automatically open.
# Sets up the python virtual environment and installs all required packages
pyenv install
poetry install
# Run unit tests
poetry run pytest --cov
# Run API on http://localhost:5000
poetry run uvicorn --host 0.0.0.0 main:app --port 5000
To enable semantic release on your repository, create a Personal Access Token and add it to your project CI variables as GITLAB_TOKEN
.
Auto formats commit messages. This hooks into semantic release and creates major/minor releases depending on the change.
The cloudbuild/container_build.yml
and policy.yaml
configs build the docker container, analyse it for vulnerabilities and only push the container to the registry if there are no vulnerabilities above a certain policy threshold in policy.yaml
.
The "Open in Cloud Shell" tutorial shows you to quickly set this up and adjust to your use case.