Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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

110 changes: 110 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! make

build:
docker build -t tsugite .

up:
docker-compose up -d

browse:
firefox http://localhost:8083 &
mskyttner marked this conversation as resolved.
Show resolved Hide resolved

21 changes: 21 additions & 0 deletions README.docker.md
Original file line number Diff line number Diff line change
@@ -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"

7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
services:

app:
image: tsugite
ports:
- "8083:8083"

8 changes: 6 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -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