Physics Derivation Graph navigation Sign in

Flask and Docker

Published 2019-05-25T15:35:00Z by Physics Derivation Graph

I wanted to improve the portability of the Physics Derivation Graph, and I recognized the value of putting the code in a Docker image. As a Docker image, anyone would be able to get started with editing and contributing quickly rather than resolving software dependencies.

In addition to improving portability, I also recognize a command-line interface is not sufficient for most users. With the code in a Docker image, another useful change would be to run a webserver in the container. The web server could both display the current state and be the interface for making edits to the content.

I have heard of nginx but not used it. Another option is lighttpd; I haven't used that either. While either of these two options would be sufficient for running static HTML content or something interactive (eg PHP or cgi), my backend code is currently Python. Therefore, I think Flask is a reasonable choice for presenting a web interface and enabling edits to the database.

Update 20200512: good explanation of the relevance of Nginx:

Update 20190602:

cd to your local copy of
docker build -t flask_ub:latest .
To run interactively and manually, use
docker run -it --publish 5000:5000 --mount type=bind,source="$(pwd)",target=/another --entrypoint /bin/bash flask_ub
and then run
python3 app/
inside the Docker container.  To run interactively automatically, use
docker run -it --publish 5000:5000 flask_ub
In either case, navigate your browser to http://localhost:5000 to use the interface.