Dockerized FastAPI boilerplate for a quick environment setup with some (opinionated) sane defaults.
Build with:
- Docker & Docker Compose (for local development)
- Tortoise-ORM with PostgreSQL
- Migrations by aerich
- User management by FastAPI-users
- Uvicorn
1. Clone the repo
$ git clone git@github.com:villeristi/fastapi-boilerplate.git2. Create the .env-file
$ cp .env.example .env3. Start the containers
$ docker-compose up -d4. Get to tha choppa container
$ docker exec -it fabp_app5. Initialize base DB-schema
$ aerich init-db # inside the container6. Create superuser
$ ./bin/createsuperuser # inside the container(6.5 Optional: Generate fake data)
$ ./bin/fakedata # inside the container7. Logging
Default logging is configured in src/util/logger.py and logs everything to stdout. To actually see what's going on in your application, just grab the logs from the container using
$ docker logs fabp_app -fUvicorn is watching the src directory by default and reloads application accordingly.
8. Done!
Now everything's set up and one can start building something useful!
- Create migrations after initializing new models / changing existing models
aerich migrate # inside the container- Apply migrations
aerich upgrade # inside the container- Fake data
- Sample CRUD-applicaiton (Items)
- Testing
- Production