Skip to content

Commit 6099bba

Browse files
authored
Merge pull request #928 from mathics/docker-doc-update
Revise docker setup instructions
2 parents 29de41a + 757bc5b commit 6099bba

7 files changed

Lines changed: 145 additions & 2 deletions

File tree

README.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,23 @@ For an experiemental Jupyter-based consoles and web interfaces see `iwolfram <ht
4444
Docker
4545
------
4646

47-
Alternatively to the installation step above, ``mathics`` can be installed and run via `docker <https://www.docker.com/>`_. Please refer to `sealemar/mathics-dockerized <https://github.com/sealemar/mathics-dockerized>`_ repo for instructions.
47+
Another way to run ``mathics`` is via `docker <https://www.docker.com/>`_ and the `Mathics docker image <https://hub.docker.com/repository/docker/mathicsorg/mathics>`_ on dockerhub.
48+
49+
To run the command-line interface using docker image:
50+
::
51+
$ docker run --rm -it --name mathics-cli -v /tmp:/usr/src/app/data mathicsorg/mathics --mode cli
52+
53+
If you want to add options add them at then end preceded with `--`: for example:
54+
55+
::
56+
$ docker run --rm -it --name mathics-cli -v /tmp:/usr/src/app/data mathicsorg/mathics --mode cli -- --help
57+
58+
To run the Django web interface using docker image:
59+
::
60+
$ docker run --rm -it --name mathics-web -p 8000:8000 -v /tmp:/usr/src/app/data mathicsorg/mathics --mode ui
61+
62+
63+
This dockerization was modified from `sealemar/mathics-dockerized <https://github.com/sealemar/mathics-dockerized>`_. See that for more details on how this works.
4864

4965
Contributing
5066
------------

app/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM python:3.7-buster
2+
3+
ENV MATHICS_HOME=/usr/src/app
4+
ENV ENTRYPOINT_COMMAND="docker run -it {MATHICS_IMAGE}"
5+
6+
WORKDIR $MATHICS_HOME
7+
8+
COPY entrypoint.sh /
9+
RUN chmod +x /entrypoint.sh
10+
11+
COPY requirements.txt ./
12+
RUN apt-get update
13+
RUN apt-get install -qq liblapack-dev llvm-dev gfortran
14+
RUN pip install --no-cache-dir -r requirements.txt
15+
# RUN python -m nltk.downloader wordnet omw
16+
COPY requirements-tmathics.txt ./
17+
RUN pip install --no-cache-dir -r requirements-tmathics.txt
18+
19+
EXPOSE 8000
20+
21+
RUN groupadd mathics && \
22+
useradd -d $MATHICS_HOME -g mathics -m -s /bin/bash mathics && \
23+
mkdir -p $MATHICS_HOME/data && \
24+
chown -R mathics:mathics $MATHICS_HOME
25+
26+
USER mathics
27+
28+
ENTRYPOINT ["/entrypoint.sh"]
29+
30+
CMD ["--help"]

app/entrypoint.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
script_cmd="${ENTRYPOINT_COMMAND:-$(basename $0)}"
4+
5+
function help() {
6+
cat <<EOF
7+
8+
Usage:
9+
$script_cmd [arg] [-- params, ...]
10+
11+
Arg:
12+
13+
-h | --help Print this help and exit
14+
15+
--pythonpath This will be added to PYTHONPATH. Example use-case - absolute path to
16+
basedir of mathics source code inside container, ie:
17+
mathics src = /usr/src/app/mathics
18+
--pythonpaht /usr/src/app
19+
20+
-m | --mode {cli|ui} Start mathics in web-ui mode (ui), or in cli mode (cli). Default is cli.
21+
See: https://github.com/mathics/Mathics/wiki/Installing#running-mathics
22+
23+
Params:
24+
25+
Everything passed after '--' will be passed to mathics as is.
26+
27+
EOF
28+
}
29+
30+
mathics_mode=cli
31+
32+
while (( $# )) ; do
33+
case "$1" in
34+
-h | --help) help ; exit ;;
35+
-m | --mode) mathics_mode="$2" ; shift 2 ;;
36+
--pythonpath) export PYTHONPATH="$2":$PYTHONPATH ; shift 2 ;;
37+
--) shift ; break ;;
38+
*) echo "Can't parse '$@'. See '$0 --help'" ; exit 1 ;;
39+
esac
40+
done
41+
42+
echo
43+
echo "~~~~ app/data has been mounted to $MATHICS_HOME/data ~~~~"
44+
echo "$ ls $MATHICS_HOME/data"
45+
ls -p $MATHICS_HOME/data
46+
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
47+
echo
48+
49+
case $mathics_mode in
50+
cli) tmathics $@ ;;
51+
ui) mathicsserver -e $@ ;;
52+
*) echo "unknown mathics_mode=$mathics_mode. See '$script_cmd --help'" ; exit 2 ;;
53+
esac

app/requirements-tmathics.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mathics
2+
colorama
3+
pygments
4+
git+https://github.com/Mathics3/tmathics

app/requirements.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
sympy>=1.6, < 1.7
2+
django >= 1.8, < 1.12
3+
mpmath>=1.1.0
4+
numpy
5+
palettable
6+
pint
7+
pydot
8+
python-dateutil
9+
colorama
10+
llvmlite
11+
requests
12+
cython
13+
scikit-image
14+
ipywidgets
15+
ipykernel
16+
requests
17+
IPython==5.0.0
18+
nltk
19+
langid
20+
pycountry
21+
pyenchant
22+
lxml
23+
matplotlib
24+
networkx
25+
# git+https://github.com/mathics/Mathics@6ec25fafd488d71e6576e2d94ad0071443a096d0
26+
git+https://github.com/mathics/Mathics

docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '2'
2+
3+
services:
4+
mathics:
5+
build: ./app
6+
image: mathicsorg/mathics:latest
7+
8+
volumes:
9+
- ./app/data:/usr/src/app/data
10+
11+
ports:
12+
- "8000:8000"

mathics/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113

114114
ROOT_URLCONF = 'mathics.urls'
115115

116-
default_pymathics_modules = ["pymathics.natlang",]
116+
# Rocky: this is probably a hack. LoadModule[] needs to handle
117+
# whatever it is that setting this thing did.
118+
default_pymathics_modules = []
117119

118120
TEMPLATES = [
119121
{

0 commit comments

Comments
 (0)