diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 00000000..4cac894d --- /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.GITHUB_TOKEN }} + - + 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..8d1c0308 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,110 @@ +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 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 + +# install tsugite app +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* ./ + +# 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 \ + && 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 + +# set up default password for noVNC login +#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 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 + +#CMD python3 Tsugite_app.py + 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 & + diff --git a/README.docker.md b/README.docker.md new file mode 100644 index 00000000..5e529ceb --- /dev/null +++ b/README.docker.md @@ -0,0 +1,21 @@ +# Tsugite in the browser + +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. + + +# Usage + +Try this oneliner to use the image built by the GitHub Action and stored in GitHub Container Registry: + + 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" + 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