Fixed VNC server functionality (#2898)

Co-authored-by: Andrey Zotov <azotov@teko.io>
This commit is contained in:
nix155
2024-12-10 19:04:08 +03:00
committed by GitHub
parent bf059715ec
commit f20c449279
3 changed files with 57 additions and 41 deletions

View File

@@ -1,11 +1,12 @@
# Stage 1: Build
FROM ubuntu:latest AS builder
# Define build image
FROM ubuntu:latest AS build
# Install essential build dependencies
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y \
&& apt install -y \
&& apt install --no-install-recommends -y \
git \
ca-certificates \
qtquickcontrols2-5-dev \
qtconnectivity5-dev \
qtbase5-private-dev \
@@ -18,26 +19,19 @@ RUN apt update && apt upgrade -y \
qtlocation5-dev \
qtmultimedia5-dev \
g++ \
make
make \
wget \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Clone the project and build it
WORKDIR /usr/local/src
RUN git clone --recursive https://github.com/cagnulein/qdomyos-zwift.git
WORKDIR /usr/local/src/qdomyos-zwift
RUN git submodule update --init src/smtpclient/ \
&& git submodule update --init src/qmdnsengine/ \
&& git submodule update --init tst/googletest/
WORKDIR /usr/local/src/qdomyos-zwift/src
RUN qmake qdomyos-zwift.pro \
&& make -j4
# Stage 2: Runtime
FROM ubuntu:latest
# Define runtime image
FROM ubuntu:latest AS runtime
# Install essential runtime dependencies
ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y \
&& apt install -y \
&& apt install --no-install-recommends -y \
libqt5bluetooth5 \
libqt5widgets5 \
libqt5positioning5 \
@@ -56,17 +50,47 @@ RUN apt update && apt upgrade -y \
libqt5location5 \
bluez \
dbus \
xfce4 \
tightvncserver \
tigervnc-standalone-server \
tigervnc-tools \
libgl1-mesa-dri \
xfonts-base \
x11-xserver-utils \
tigervnc-common \
net-tools \
&& rm -rf /var/lib/apt/lists/*
# Stage 1: Build
FROM build AS builder
# Clone the project and build it
WORKDIR /usr/local/src
RUN git clone --recursive https://github.com/cagnulein/qdomyos-zwift.git
WORKDIR /usr/local/src/qdomyos-zwift
RUN git submodule update --init src/smtpclient/ \
&& git submodule update --init src/qmdnsengine/ \
&& git submodule update --init tst/googletest/
WORKDIR /usr/local/src/qdomyos-zwift/src
RUN qmake qdomyos-zwift.pro \
&& make -j4
# Stage 2: Runtime
FROM runtime
# Copy the built binary to /usr/local/bin
COPY --from=builder /usr/local/src/qdomyos-zwift/src/qdomyos-zwift /usr/local/bin/qdomyos-zwift
# Configure VNC
RUN mkdir -p /root/.vnc \
&& echo "password" | vncpasswd -f > /root/.vnc/passwd \
&& chmod 600 /root/.vnc/passwd
# VNC configuration
RUN mkdir -p ~/.vnc && \
echo "securepassword" | vncpasswd -f > ~/.vnc/passwd && \
chmod 600 ~/.vnc/passwd
# .Xauthority configuration
RUN touch /root/.Xauthority
ENV DISPLAY=:99
# Start VNC server with authentication
CMD vncserver :99 -depth 24 -localhost no -xstartup qdomyos-zwift && \
sleep infinity
# Start VNC and the application
CMD tightvncserver && qdomyos-zwift

View File

@@ -1,2 +1,2 @@
#!/bin/bash
docker build -t qdomyos-zwift .
docker build -t qdomyos-zwift-vnc .

View File

@@ -1,18 +1,10 @@
services:
qdomyos-zwift:
qdomyos-zwift-vnc:
image: qdomyos-zwift-vnc
container_name: qdomyos-zwift
privileged: true
network_mode: "host"
environment:
- DISPLAY=${DISPLAY}
- USER=docker
container_name: qdomyos-zwift-vnc
privileged: true # Required for Bluetooth functionality
network_mode: "host" # Used to access host Bluetooth and D-Bus
volumes:
- /dev:/dev
- /run/dbus:/run/dbus
- /tmp/.X11-unix:/tmp/.X11-unix
- ./.config:/root/.config
stdin_open: true
tty: true
restart: "no"
command: bash -c "tightvncserver && ./qdomyos-zwift"
- /dev:/dev # Forward host devices (for Bluetooth)
- /run/dbus:/run/dbus # Forward D-Bus for Bluetooth interaction
restart: "no" # Do not restart the container automatically