Stack:
FastAPI Uvicorn Gunicorn.Before: investigate
.env.example and fill .env.[prod/dev/test].Note: for
prod you have to generate local SSL cert and tweak hosts to local run (will describe it's later).Test [tests (pytest), linting (flake8, isort), type-checking (mypy)]:$ make testProd [Nginx + Gunicorn]:$ make prodDev [Uvicorn]:$ make devClean docker stuff:
$ make test-down
$ make prod-down
$ make dev-down
$ make cleanServe postgres DB for app.
[I'm sure You understand that you have to put DB URL to that DB in .env files.]
Put
APP_ENV in .env/environment.Test:$ make local-test
# or
$ make lint
$ pytestProd:$ python app/__main__.pyDev:$ python app/__main__.pyProd and Dev runners depend on APP_ENV variable.Install mkcert.
$ mkcert api.myvocab.io localhost 127.0.0.1 ::1Put this cert under ./nginx/certs. [Use other domains? Substitute all occurrences]
Link cert to nginx conf.d (to local run):
$ cd /etc/nginx/conf.d
$ ln -s <path-to-cert> .
$ ln -s <path-to-cert-key> .Tweak /etc/hosts file:
...
# custom domains
127.0.0.1 gunicorn_host
127.0.0.1 api.myvocab.ioYou're ready to run both as locally as in Docker.
Serve nginx to local run.
noli esse irrumatus - pone stellam.