Sign inSign up

lasuillard/mockbook

By lasuillard

•Updated 2 days ago

Docker image for writing and serving mocks with Jupyter and FastAPI.

Image
Developer tools
0

5.4K

lasuillard/mockbook repository overview

⁠mockbook

License: MIT Docker Image Version

Docker image for writing and serving mocks with Jupyter and FastAPI.

Demo

⁠✨ Features

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⁠

⁠🚀 How to use

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:main

The 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
⁠⚙️ Environment variables
KeyDescription
MOCKBOOK_ARGSExtra arguments for Mockbook's uvicorn server (uvicorn).
MOCKBOOK_AUTORELOAD_DISABLEDDisable auto reloading (--reload).
May be useful for certain environments (such as testing) where reloading is not desirable.
JUPYTERLAB_ARGSExtra arguments for JupyterLab (jupyter lab).
JUPYTERLAB_DISABLEDDisable the JupyterLab service.
May be useful for certain environments (such as testing) where the notebook is unnecessary.
NGINX_ARGSExtra arguments to pass to NGINX (nginx).
NGINX_DISABLEDDisable the NGINX service.
NGINX_RELOADER_DISABLEDDisable the NGINX reloader.
⁠📂 Mount points
  • /app/mockbook/notebooks for Jupyter notebooks. The Mockbook app watches /app/mockbook/ for changes and reloads FastAPI automatically.
  • /app/mockbook/nginx for NGINX configuration. The auto reloader watches this directory and reloads NGINX automatically.

Please check the examples⁠ directory for more usage examples.

⁠💖 Contributing

Please refer to CONTRIBUTING.md⁠ for more information on how to contribute to this project.

⁠📜 License

This project is licensed under the MIT License.

Tag summary

Content type

Image

Digest

sha256:d641f1e5d…

Size

141.4 MB

Last updated

8 days ago

docker pull lasuillard/mockbook