diff --git a/.gitignore b/.gitignore index c75b45b..68e8bd0 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,5 @@ coverage.xml # Sphinx documentation docs/_build/ +# symoro-robot +symoro-robots diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..55caf41 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,57 @@ +FROM ubuntu:18.04 + +# essential packages +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + xauth \ + git \ + wget \ + nano \ + sudo \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +# user +ARG USER_UID=1001 +ARG GROUP_UID=1001 +ARG USERNAME=user + +RUN groupadd --gid $GROUP_UID $USERNAME \ + && useradd --uid $USER_UID --gid $GROUP_UID -m $USERNAME \ + && echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +WORKDIR /home/$USERNAME + +# symoro +RUN git -c http.sslVerify=false clone https://github.com/fleborne/symoro.git /home/$USERNAME/symoro + +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + python2.7 \ + virtualenv \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + libgtk-3-dev \ + freeglut3-dev \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +COPY ./requirements.txt /home/$USERNAME + +RUN /usr/bin/virtualenv --python=python2.7 symoro-env && \ + . /home/$USERNAME/symoro-env/bin/activate && \ + pip install -r /home/$USERNAME/requirements.txt && \ + wget https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04/wxPython-4.0.7-cp27-cp27mu-linux_x86_64.whl && \ + pip install wxPython-4.0.7-cp27-cp27mu-linux_x86_64.whl && \ + cd /home/$USERNAME/symoro && \ + python setup.py install + +RUN chown -R $USERNAME:$USERNAME /home/$USERNAME + +# entrypoint +COPY ./entrypoint.sh /entrypoint.sh +RUN sudo chmod +x /entrypoint.sh + +SHELL [ "/bin/bash", "-c" ] +ENTRYPOINT ["/entrypoint.sh"] +CMD [ "/bin/bash" ] \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..5d35b71 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,34 @@ +# Docker environment for symoro + +## Pre-requisites + +### For Linux +- Install [Docker Engine](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository); +- Do the [post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/); + +### For WSL2 +- Install [WSL2](https://learn.microsoft.com/fr-fr/windows/wsl/install); +- Install [Docker Desktop](https://docs.docker.com/desktop/install/windows-install/); +- Install [Terminal](https://learn.microsoft.com/fr-fr/windows/terminal/install). + +Then, install the Docker image and create a container. + +## Docker Hub + +The image is available on the Docker Hub : see [baaluidnrey/symoro](https://hub.docker.com/repository/docker/baaluidnrey/symoro/general). + +## Build from sources + +```bash +# 1. clone symoro +git clone -b docker https://github.com/baaluidnrey/symoro + +# 2. install the image +cd symoro/docker +./install_docker.sh + +# 3. launch symoro +./start_symoro.sh +``` + +The volume `symoro-robots` is mounted in the docker container to the location of the saved files. \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100644 index 0000000..8ddacc9 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# xauth --- +if [[ -f /dot.Xauthority ]]; then + xauth merge /dot.Xauthority +fi +# ---------- + +# symoro --- +source /home/user/symoro-env/bin/activate +symoro-bin +# ---------- \ No newline at end of file diff --git a/docker/install_image.sh b/docker/install_image.sh new file mode 100755 index 0000000..51a9975 --- /dev/null +++ b/docker/install_image.sh @@ -0,0 +1,2 @@ +docker build --tag symoro . +docker image prune \ No newline at end of file diff --git a/docker/requirements.txt b/docker/requirements.txt new file mode 100644 index 0000000..f7fc779 --- /dev/null +++ b/docker/requirements.txt @@ -0,0 +1,4 @@ +sympy==0.7.3 +numpy==1.6.1 +# wxPython >= 2.8.12 +PyOpenGL==3.0.1b2 \ No newline at end of file diff --git a/docker/start_symoro.sh b/docker/start_symoro.sh new file mode 100755 index 0000000..d95002e --- /dev/null +++ b/docker/start_symoro.sh @@ -0,0 +1,24 @@ +if [ ! -d $PWD/../symoro-robots ]; then + mkdir $PWD/../symoro-robots + chgrp docker $PWD/../symoro-robots + chmod g+rw $PWD/../symoro-robots +fi + +# Settings to use graphical applications : linux or wsl ? +if [ -f /tmp/.X11-unix ]; then + DOCKER_GUI="--volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --volume="$XAUTHORITY:/dot.Xauthority"" +elif [ -d /mnt/wslg ]; then + DOCKER_GUI="--volume="/mnt/wslg:/mnt/wslg" --volume="/mnt/wslg/.X11-unix:/tmp/.X11-unix"" +else + DOCKER_GUI="" +fi + +docker run -it --rm \ +--env DISPLAY \ +--env QT_X11_NO_MITSHM=1 \ +--net="host" \ +$DOCKER_GUI \ +--user user \ +--name="symoro" \ +--volume="$PWD/../symoro-robots:/home/user/symoro-robots" \ +symoro \ No newline at end of file