Docker image for writing and serving mocks with Jupyter and FastAPI.
Mockbook is a simple FastAPI application with the following features:
- Write mock endpoints with a Jupyter Notebook to manage mock endpoints
- Serve mock endpoints with a FastAPI server and live reloading.
- Preconfigured NGINX reverse proxy with a reloader triggered by configuration file changes for flexible mocking.
- Preinstalled libraries for writing mocks, such as: factory-boy, Faker
To pull and run the image from Docker Hub, run:
$ docker run --rm \
-p 127.0.0.1:80:80 \
-e JUPYTERLAB_ARGS='--NotebookApp.token=token' \
lasuillard/mockbook:mainThe following endpoints are available (via NGINX):
graph LR
browser[Browser]
mockbook[Mockbook]
jupyterlab[JupyterLab]
nginx[NGINX]
browser -->|http://localhost:80| nginx
nginx -->|/| mockbook
nginx -->|/jupyter| jupyterlab
- http://localhost:80/docs for FastAPI OpenAPI documentation
- http://localhost:80/jupyter for the JupyterLab web UI
| Key | Description |
|---|---|
MOCKBOOK_ARGS |
Extra arguments for Mockbook's uvicorn server (uvicorn). |
MOCKBOOK_AUTORELOAD_DISABLED |
Disable auto reloading (--reload). May be useful for certain environments (such as testing) where reloading is not desirable. |
JUPYTERLAB_ARGS |
Extra arguments for JupyterLab (jupyter lab). |
JUPYTERLAB_DISABLED |
Disable the JupyterLab service. May be useful for certain environments (such as testing) where the notebook is unnecessary. |
NGINX_ARGS |
Extra arguments to pass to NGINX (nginx). |
NGINX_DISABLED |
Disable the NGINX service. |
NGINX_RELOADER_DISABLED |
Disable the NGINX reloader. |
/app/mockbook/notebooksfor Jupyter notebooks. The Mockbook app watches/app/mockbook/for changes and reloads FastAPI automatically./app/mockbook/nginxfor NGINX configuration. The auto reloader watches this directory and reloads NGINX automatically.
Please check the examples directory for more usage examples.
Please refer to CONTRIBUTING.md for more information on how to contribute to this project.
This project is licensed under the MIT License.
