From 6166bdbb4a25115d19e1bda0ce65c8105dc61cce Mon Sep 17 00:00:00 2001 From: Roger Wilco Date: Mon, 13 Dec 2021 08:39:51 +0100 Subject: [PATCH 1/5] docker build for running tsugite in web browser --- .github/workflows/push.yml | 48 +++++++++++++++++ Dockerfile | 108 +++++++++++++++++++++++++++++++++++++ README.docker.md | 14 +++++ docker-compose.yml | 7 +++ requirements.txt | 8 ++- supervisord.conf | 27 ++++++++++ 6 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push.yml create mode 100644 Dockerfile create mode 100644 README.docker.md create mode 100644 docker-compose.yml create mode 100644 supervisord.conf diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..e56bf0e2 --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,48 @@ +on: + workflow_dispatch: + push: + paths: + - '*' + - '.github/workflows/push.yml' + +jobs: + tsugite-push: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v2 + - + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + ghcr.io/${{ github.repository_owner }}/tsugite + tags: | + type=raw,value=1.0.${{ github.run_number }},priority=1000 + type=ref,event=branch + type=sha + type=raw,value=latest + - + name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Login to Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.CR_PAT }} + - + name: Docker build and push + uses: docker/build-push-action@v2 + with: + context: . + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + push: true + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0393cd6c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,108 @@ +FROM debian:bullseye as builder + +RUN apt-get update && apt-get install -y \ + libtool-bin \ + autoconf \ + python3-pip \ + libx11-dev \ + libxext-dev \ + x11proto-core-dev \ + x11proto-gl-dev \ + libglew-dev \ + freeglut3-dev \ + bison \ + flex \ + wget \ + pkg-config \ + zlib1g-dev \ + llvm-dev \ + meson \ + libxcb-randr0-dev \ + libunwind-dev \ + x11-xserver-utils \ + libxrandr-dev \ + mesa-utils + +RUN pip3 install mako +RUN wget -O mesa.tar.xz https://archive.mesa3d.org/mesa-21.3.1.tar.xz +RUN tar xf mesa.tar.xz +RUN mkdir mesa-21.3.1/build +WORKDIR mesa-21.3.1/build + +RUN meson \ + -D glx=gallium-xlib \ + -D gallium-drivers=swrast \ + -D platforms=x11 \ + -D dri3=disabled \ + -D dri-drivers="" \ + -D vulkan-drivers="" \ + -D buildtype=release \ + -D optimization=3 + +RUN ninja + +RUN ninja install + +RUN tar -cf /softpipe.tar /usr/local/lib/x86_64-linux-gnu/libglapi.so.0.0.0 /usr/local/lib/x86_64-linux-gnu/libGLESv1_CM.so.1.1.0 /usr/local/lib/x86_64-linux-gnu/libGLESv2.so.2.0.0 /usr/local/lib/x86_64-linux-gnu/libGL.so.1.5.0 /usr/local/include/KHR/khrplatform.h /usr/local/include/GLES/egl.h /usr/local/include/GLES/gl.h /usr/local/include/GLES/glext.h /usr/local/include/GLES/glplatform.h /usr/local/include/GLES2/gl2.h /usr/local/include/GLES2/gl2ext.h /usr/local/include/GLES2/gl2platform.h /usr/local/include/GLES3/gl3.h /usr/local/include/GLES3/gl31.h /usr/local/include/GLES3/gl32.h /usr/local/include/GLES3/gl3ext.h /usr/local/include/GLES3/gl3platform.h /usr/local/include/GL/gl.h /usr/local/include/GL/glcorearb.h /usr/local/include/GL/glext.h /usr/local/include/GL/glx.h /usr/local/include/GL/glxext.h /usr/local/share/drirc.d/00-mesa-defaults.conf /usr/local/lib/x86_64-linux-gnu/pkgconfig/glesv1_cm.pc /usr/local/lib/x86_64-linux-gnu/pkgconfig/glesv2.pc /usr/local/lib/x86_64-linux-gnu/pkgconfig/gl.pc + +# multistage build, second phase (remove build deps, image goes from 1.7GB to a third of that) + +FROM debian:bullseye + +COPY --from=builder /softpipe.tar / + +RUN cd / && tar -xf /softpipe.tar && rm /softpipe.tar + +RUN apt -y update && apt install -y --no-install-recommends \ + python3-pyqt5.qtopengl \ + python3-pip \ + libunwind-dev + +WORKDIR /code +COPY requirements.txt . +RUN python3 -m pip install --upgrade pip +RUN pip3 install -r requirements.txt + +COPY setup/ . +COPY my_joint* ./ + +ENV XVFB_WHD="1920x1080x24"\ + DISPLAY=":0.0" \ + LIBGL_ALWAYS_SOFTWARE="1" \ + GALLIUM_DRIVER="softpipe" + +# add supervisord and a novnc websockified UI to the app + +RUN apt-get install -y --no-install-recommends git && \ + git clone https://github.com/kanaka/noVNC.git /root/noVNC \ + && git clone https://github.com/kanaka/websockify /root/noVNC/utils/websockify \ + && rm -rf /root/noVNC/.git \ + && rm -rf /root/noVNC/utils/websockify/.git \ + && apt-get remove -y git + +RUN cp /root/noVNC/vnc.html /root/noVNC/index.html + +RUN apt-get install -y --no-install-recommends \ + x11vnc \ + tini \ + supervisor \ + socat \ + autocutsel \ + fluxbox \ + xvfb \ + procps + +#RUN cp /etc/X11/xinit/xinitrc /root/.xinitrc +RUN mkdir ~/.vnc && x11vnc -storepasswd tsugite ~/.vnc/passwd + +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +EXPOSE 8083 +ENTRYPOINT [ "tini", "--" ] + +ENV DISPLAY_WIDTH="1920" \ + DISPLAY_HEIGHT="1080" + +CMD /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf + +#CMD python3 Tsugite_app.py + diff --git a/README.docker.md b/README.docker.md new file mode 100644 index 00000000..876df24c --- /dev/null +++ b/README.docker.md @@ -0,0 +1,14 @@ +# Tsugite in the browser + +Debian with Mesa libraries and Gallium driver "softpipe" provides OpenGL support inside a Docker container without the need for a GPU. + +A web UI based on noVNC exposes the python app for usage from a web browser. + +Should therefore run on most hardware configurations, albeit slower. + +# Usage + +docker run --rm -port "8083:8083" tsugite + +Then open the browser at http://localhost:8083 and login with password "tsugite" + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..bf313603 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,7 @@ +services: + + app: + image: tsugite + ports: + - "8083:8083" + diff --git a/requirements.txt b/requirements.txt index 83973561..e15ac2d9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,11 @@ multipledispatch==0.6.0 numpy==1.20.3 Pillow==8.3.2 -PyOpenGL==3.1.5 -PyQt5==5.15.4 +#PyOpenGL==3.1.5 +#PyQt5==5.15.6 +PyQt5 +PyOpenGL pyrr==0.10.3 six==1.15.0 +pbr==5.8.0 +testresources==2.0.1 diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 00000000..3270bda9 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,27 @@ +[supervisord] +nodaemon=true +root=true + +[program:X11] +command=Xvfb :0 -screen 0 "%(ENV_DISPLAY_WIDTH)s"x"%(ENV_DISPLAY_HEIGHT)s"x24 +autorestart=true + +[program:x11vnc] +command=/usr/bin/x11vnc -rfbauth /root/.vnc/passwd +autorestart=true + +[program:novnc] +command=/root/noVNC/utils/novnc_proxy --vnc localhost:5900 --listen 8083 +autorestart=true + +[program:socat] +command=socat tcp-listen:6000,reuseaddr,fork unix:/tmp/.X11-unix/X0 +autorestart=true + +[program:fluxbox] +command=fluxbox +autorestart=true + +[program:tsugite] +command=sh -c "cd /code && python3 Tsugite_app.py" +autorestart=true From 0e47fb3966a69fa562b23156819ff1354abc6803 Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Mon, 13 Dec 2021 09:11:23 +0100 Subject: [PATCH 2/5] use gh token --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e56bf0e2..4cac894d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -36,7 +36,7 @@ jobs: with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Docker build and push uses: docker/build-push-action@v2 From 164a2849aba57d765ba1ff6d588e1f6c2c19dc27 Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Mon, 13 Dec 2021 10:22:57 +0100 Subject: [PATCH 3/5] add Makefile for local docker build --- Makefile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..ca7ad6ed --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +#! make + +build: + docker build -t tsugite . + +up: + docker-compose up -d + +browse: + firefox http://localhost:8083 & + From 204089cace37649fb261098c6810c2b6d5350c63 Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Sat, 18 Dec 2021 16:10:29 +0100 Subject: [PATCH 4/5] fix docs, cleanup --- Dockerfile | 30 ++++++++++++++++-------------- README.docker.md | 9 ++++++--- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0393cd6c..8d1c0308 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,18 +41,20 @@ RUN meson \ RUN ninja -RUN ninja install - -RUN tar -cf /softpipe.tar /usr/local/lib/x86_64-linux-gnu/libglapi.so.0.0.0 /usr/local/lib/x86_64-linux-gnu/libGLESv1_CM.so.1.1.0 /usr/local/lib/x86_64-linux-gnu/libGLESv2.so.2.0.0 /usr/local/lib/x86_64-linux-gnu/libGL.so.1.5.0 /usr/local/include/KHR/khrplatform.h /usr/local/include/GLES/egl.h /usr/local/include/GLES/gl.h /usr/local/include/GLES/glext.h /usr/local/include/GLES/glplatform.h /usr/local/include/GLES2/gl2.h /usr/local/include/GLES2/gl2ext.h /usr/local/include/GLES2/gl2platform.h /usr/local/include/GLES3/gl3.h /usr/local/include/GLES3/gl31.h /usr/local/include/GLES3/gl32.h /usr/local/include/GLES3/gl3ext.h /usr/local/include/GLES3/gl3platform.h /usr/local/include/GL/gl.h /usr/local/include/GL/glcorearb.h /usr/local/include/GL/glext.h /usr/local/include/GL/glx.h /usr/local/include/GL/glxext.h /usr/local/share/drirc.d/00-mesa-defaults.conf /usr/local/lib/x86_64-linux-gnu/pkgconfig/glesv1_cm.pc /usr/local/lib/x86_64-linux-gnu/pkgconfig/glesv2.pc /usr/local/lib/x86_64-linux-gnu/pkgconfig/gl.pc +RUN mkdir installdir && \ + DESTDIR=installdir ninja install && \ + cd installdir && \ + tar -cf /softpipe.tar . # multistage build, second phase (remove build deps, image goes from 1.7GB to a third of that) FROM debian:bullseye +# install mesa llvmpipe and softpipe GALLIUM drivers for non-GPU OpenGL COPY --from=builder /softpipe.tar / +RUN cd / && tar -xf /softpipe.tar -RUN cd / && tar -xf /softpipe.tar && rm /softpipe.tar - +# install tsugite app RUN apt -y update && apt install -y --no-install-recommends \ python3-pyqt5.qtopengl \ python3-pip \ @@ -66,13 +68,7 @@ RUN pip3 install -r requirements.txt COPY setup/ . COPY my_joint* ./ -ENV XVFB_WHD="1920x1080x24"\ - DISPLAY=":0.0" \ - LIBGL_ALWAYS_SOFTWARE="1" \ - GALLIUM_DRIVER="softpipe" - -# add supervisord and a novnc websockified UI to the app - +# add supervisord and a novnc websockified UI in front of the app RUN apt-get install -y --no-install-recommends git && \ git clone https://github.com/kanaka/noVNC.git /root/noVNC \ && git clone https://github.com/kanaka/websockify /root/noVNC/utils/websockify \ @@ -92,6 +88,7 @@ RUN apt-get install -y --no-install-recommends \ xvfb \ procps +# set up default password for noVNC login #RUN cp /etc/X11/xinit/xinitrc /root/.xinitrc RUN mkdir ~/.vnc && x11vnc -storepasswd tsugite ~/.vnc/passwd @@ -99,8 +96,13 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf EXPOSE 8083 ENTRYPOINT [ "tini", "--" ] -ENV DISPLAY_WIDTH="1920" \ - DISPLAY_HEIGHT="1080" +ENV XVFB_WHD="1200x768x24"\ + DISPLAY=":0.0" \ + LIBGL_ALWAYS_SOFTWARE="1" \ + GALLIUM_DRIVER="llvmpipe" + +ENV DISPLAY_WIDTH="1600" \ + DISPLAY_HEIGHT="1024" CMD /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf diff --git a/README.docker.md b/README.docker.md index 876df24c..69cdf4b5 100644 --- a/README.docker.md +++ b/README.docker.md @@ -1,14 +1,17 @@ # Tsugite in the browser -Debian with Mesa libraries and Gallium driver "softpipe" provides OpenGL support inside a Docker container without the need for a GPU. +Debian with Mesa libraries and Gallium drivers "llvmpipe" and "softpipe" provides OpenGL support inside a Docker container without the need for a GPU. + +Should therefore run on most hardware configurations, albeit slower than when utilizing hardware with GPUs. A web UI based on noVNC exposes the python app for usage from a web browser. -Should therefore run on most hardware configurations, albeit slower. # Usage -docker run --rm -port "8083:8083" tsugite +After a local build, use: + + docker run --rm -port "8083:8083" tsugite Then open the browser at http://localhost:8083 and login with password "tsugite" From b5332ff9fb5029ca8f939e88398bb07d577dc20d Mon Sep 17 00:00:00 2001 From: Markus Skyttner Date: Mon, 31 Jan 2022 16:09:26 +0100 Subject: [PATCH 5/5] update README for docker container --- README.docker.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.docker.md b/README.docker.md index 69cdf4b5..5e529ceb 100644 --- a/README.docker.md +++ b/README.docker.md @@ -9,9 +9,13 @@ A web UI based on noVNC exposes the python app for usage from a web browser. # Usage -After a local build, use: +Try this oneliner to use the image built by the GitHub Action and stored in GitHub Container Registry: - docker run --rm -port "8083:8083" tsugite + docker run --rm -p "8083:8083" ghcr.io/marialarsson/tsugite + +If you use "make build" to build locally instead, you can start the app with: + + docker run --rm -p "8083:8083" tsugite Then open the browser at http://localhost:8083 and login with password "tsugite"