From 6000387a24e43400dcccf68d4fcf8a3fa6863b21 Mon Sep 17 00:00:00 2001 From: Aline Baudry Date: Thu, 27 Mar 2025 11:26:44 +0100 Subject: [PATCH 1/5] creation of a docker environment --- .gitignore | 2 ++ docker/Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++++ docker/entrypoint.sh | 12 +++++++++ docker/install_image.sh | 5 ++++ docker/requirements.txt | 4 +++ docker/start_symoro.sh | 22 +++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/entrypoint.sh create mode 100755 docker/install_image.sh create mode 100644 docker/requirements.txt create mode 100755 docker/start_symoro.sh 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..349ffbd --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,54 @@ +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 \ + && rm -rf /var/lib/apt/lists/* + +RUN apt-get update && apt-get install -q -y --no-install-recommends \ + libgtk-3-dev \ + && 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/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..885434d --- /dev/null +++ b/docker/install_image.sh @@ -0,0 +1,5 @@ +docker build --tag symoro \ +--build-arg USER_UID=$(id -u) \ +--build-arg GROUP_UID=$(id -g) . + +docker image prune -f \ 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..fe50220 --- /dev/null +++ b/docker/start_symoro.sh @@ -0,0 +1,22 @@ +if [ ! -d $PWD/../symoro-robots ]; then + mkdir $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 From a59682ecc0a891befe527f8517752367dfe0b3b9 Mon Sep 17 00:00:00 2001 From: Aline Baudry Date: Thu, 27 Mar 2025 11:59:43 +0100 Subject: [PATCH 2/5] docker: add freeglut3-dev --- docker/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index 349ffbd..55caf41 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -27,10 +27,13 @@ RUN git -c http.sslVerify=false clone https://github.com/fleborne/symoro.git /ho 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 From 27c5a37d8386f136ea85190f592acb91935d2dbb Mon Sep 17 00:00:00 2001 From: Aline Baudry Date: Thu, 27 Mar 2025 12:09:59 +0100 Subject: [PATCH 3/5] docker: add README --- docker/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 docker/README.md diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..708f7cf --- /dev/null +++ b/docker/README.md @@ -0,0 +1,30 @@ +# 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. + +## Building and starting the environment + +```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 From 60885e35fe264b79d84540938ec310aa78b2f3df Mon Sep 17 00:00:00 2001 From: Aline Baudry Date: Thu, 27 Mar 2025 15:20:46 +0100 Subject: [PATCH 4/5] docker: fixes symoro-robots folder permissions for mounting --- docker/install_image.sh | 7 ++----- docker/start_symoro.sh | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docker/install_image.sh b/docker/install_image.sh index 885434d..51a9975 100755 --- a/docker/install_image.sh +++ b/docker/install_image.sh @@ -1,5 +1,2 @@ -docker build --tag symoro \ ---build-arg USER_UID=$(id -u) \ ---build-arg GROUP_UID=$(id -g) . - -docker image prune -f \ No newline at end of file +docker build --tag symoro . +docker image prune \ No newline at end of file diff --git a/docker/start_symoro.sh b/docker/start_symoro.sh index fe50220..d95002e 100755 --- a/docker/start_symoro.sh +++ b/docker/start_symoro.sh @@ -1,5 +1,7 @@ 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 ? @@ -19,4 +21,4 @@ $DOCKER_GUI \ --user user \ --name="symoro" \ --volume="$PWD/../symoro-robots:/home/user/symoro-robots" \ -symoro +symoro \ No newline at end of file From cb3fa8b42808ce23c1e237d10fd4f1b11a5a81a1 Mon Sep 17 00:00:00 2001 From: Aline Baudry Date: Thu, 27 Mar 2025 15:30:03 +0100 Subject: [PATCH 5/5] docker: add docker hub link to the image --- docker/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 708f7cf..5d35b71 100644 --- a/docker/README.md +++ b/docker/README.md @@ -13,7 +13,11 @@ Then, install the Docker image and create a container. -## Building and starting the environment +## 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