building a docker image for the Physics Derivation Graph
Published 2018-06-02T14:20:00.003Z by Physics Derivation Graph
Requirements
In order to build the Physics Derivation Graph in a Docker image, the minimum functionality needed is
Compile .tex files to .pdf and .png (LaTeX)
Compile .gv files to .png (GraphViz)
Run a webserver (eg flask or nginx or lighthttpd)
Run .py scripts (Python 3)
Read SQLite
In this post I explore whether Alpine is a sufficient OS. If not, Ubuntu is a candidate OS which supports the needed functionality.
Alpine-based
The build will be executed from the "proofofconcept" folder because the contents of the Docker image depend on files in the v4_file_per_expression/ folder.
cd proofofconcept mkdir sandbox/docker_images/python_alpine cat > sandbox/docker_images/python_alpine/Dockerfile << EOF FROM python:2.7-alpine MAINTAINER My Name <my.email.address@gmail.com> LABEL distro_style="apk" distro="alpine" arch="x86_64" operatingsystem="linux" RUN apk add --update --no-cache graphviz RUN apk add --update --no-cache texlive-full RUN apk add --update --no-cache texlive RUN pip install pyyaml RUN pip install sympy RUN mkdir /derivations RUN mkdir /inference_rules ADD ./v4_file_per_expression/bin/interactive_user_prompt.py interactive_user_prompt.py ADD ./v4_file_per_expression/lib/lib_physics_graph.py /lib/lib_physics_graph.py ADD ./v4_file_per_expression/inference_rules/* /inference_rules/ #WORKDIR /bin CMD ["python", "interactive_user_prompt.py"]
EOF
The above Dockerfile fails due to "texlive" and "texlive-full" not existing for alpine.
Now that the Dockerfile exists, we can build the image: docker build --tag python_alpine/example sandbox/docker_images/python_alpine/
and run it to get the interactive prompt: docker run -ti python_alpine/example
Ubuntu-based
cd proofofconcept mkdir sandbox/docker_images/python_ubuntu