Skip to content

Commit 923977e

Browse files
committed
Updated documentation
1 parent 4480df9 commit 923977e

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,56 @@
22

33
[![Build](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml/badge.svg)](https://github.com/MrMatOrg/mrmat-python-api-fastapi/actions/workflows/build.yml)
44

5+
Boilerplate (and playground) for a code-first Python FastAPI API.
56

6-
Boilerplate (and playground) for a code-first Python FastAPI API, with all the bells and whistles we've come to expect.
7+
## How to build this
78

9+
Create a virtual environment, then:
10+
11+
```shell
12+
(venv) $ pip install -r requirements.txt
13+
(venv) $ python python -m build -n --wheel
14+
```
15+
16+
If you intend to run the testsuite or work on the code, then also install the requirements from `requirements.dev.txt`. You can run the testsuite using
17+
18+
```shell
19+
(venv) $ PYTHONPATH=src pytest tests
20+
```
21+
22+
The resulting wheel is installable and knows its runtime dependencies. Any locally produced wheel will have version 0.0.0.dev0. This is intentional to distinguish local versions from those that are produced as releases in GitHub. You can override this behaviour by setting the `MRMAT_VERSION` environment variable to the desired version.
23+
24+
You can produce a container image and associated Helm chart using the provided Makefile:
25+
26+
```shell
27+
$ make container
28+
29+
# Optionally install the produced container image in the current Kubernetes context
30+
$ make helm-install
31+
```
32+
33+
## How to run this
34+
35+
To run a local development instance straight from the code:
36+
37+
```shell
38+
$ fastapi dev src/mrmat_python_api_fastapi/app.py
39+
```
40+
41+
To run from an installed wheel:
42+
43+
```shell
44+
$ uvicorn --host 0.0.0.0 --port 8000 mrmat_python_api_fastapi.app:app
45+
```
46+
47+
Or you can just start the container image or Helm chart. Both are declared in `var/container` and `var/helm` respectively and used by the top-level Makefile.
48+
49+
## How to configure this
50+
51+
When you do not explicitly configure anything the app will use an ephemeral in-memory SQLite database. You can change this to PostgreSQL by:
52+
53+
* overriding the `config.db_url` variable of the Helm chart, or
54+
* setting the `APP_CONFIG_DB_URL` environment variable, or
55+
* creating a config file in JSON setting `db_url`
56+
57+
The app will pick up the config file from the path set in the `APP_CONFIG` environment variable, if it is set. Note that the `APP_CONFIG_DB_URL` environment variable overrides the setting in the configuration file.

0 commit comments

Comments
 (0)