/python-microservice-template

Cookiecutter template to generate python grpc microservices

Primary LanguagePythonMIT LicenseMIT

Python microservice template

Cookiecutter template to generate python grpc microservices.

Look at generated service example and example protocol buffer repository.

What's included

  • Nix shell configuration to start faster than anybody if you use Nix
  • Poetry to manage dependencies and all the Python staff
  • Few GRPC and protocol buffers related libs
  • Great PostgreSQL driver asyncpg and pretty wrapper asyncpg-engine
  • Click based cli
  • Some linting staff, like flake8 with a lot of plugins, isort, mypy and black formatter (already configured!)
  • pytest and some required plugins
  • Nice pdb replacement pdb++
  • Simple helm chart to deploy to k8s
  • Github Actions workflow with testing, releasing to Github Registry and deployment setup to Yandex.Cloud

Github Actions

Before using Github Actions you should add PAT as secret named ROBOT_TOKEN (use special robot user, but personal token is okay too), otherwise CI will fail on git submodules checkout.

Also you should complete the following steps to deploy to Yandex.Cloud:

Helm

Helm chart in repo is really very simple. You should edit it manually if you need some customization (and you need it).

Database migrations

You can see that Github Actions, Dockerfile and k8s use go-migrate tool to migrate database. All existing migration tools are bad, but this tool is best of them. So it is my preferred choice.

License

There are no LICENSE file in generated project, so add it yourself.