Saturday, May 25, 2019

task list for SQL and Docker and Flask

Ordered tasks below. None of these tasks are extraordinary.
  • Convert database from CSV files to single .sqlite3 database. 
  • Rewrite interface to database to read/write .sqlite3 rather than from/to CSV

  • Create Docker image that supports Python Flask and Latex and Graphviz [done]
  • Put current scripts inside Docker image; mount external data; be able to edit content from within container
  • Run static content in Docker image and display images in web browser
  • Rewrite command-line editing interface to use Python Flask as web interface

Update 20190602: created a Docker container that supports Python Flask and Latex. I can generate a PNG from user entered strings.

Flask and Docker

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: https://rushter.com/blog/gunicorn-and-low-and-slow-attacks/

Update 20190602:

cd to your local copy of
https://github.com/allofphysicsgraph/proofofconcept/tree/gh-pages/sandbox/docker_images/flask_ubuntu
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/controller.py
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.