linux-desktop-vnc / Dockerfile
Divd123's picture
Initial deployment: Linux Desktop VNC with hardened startup sequence
8a7a0c0
Raw History Blame Contribute Delete
3.22 kB
# =============================================================================
# Linux Desktop (Fluxbox + TigerVNC) for Hugging Face Spaces
# Headless container orchestration with hardened startup & resource shaping.
# =============================================================================
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
HOME=/home/user \
USER=user \
DISPLAY=:99
# -----------------------------------------------------------------------------
# System packages
# - tigervnc-standalone-server: provides Xvnc (single-layer X11 + VNC server)
# - fluxbox: lightweight window manager (low RAM footprint)
# - novnc + websockify: browser <-> VNC bridge
# - socat: used for the temporary HTTP "fast-ack" health-check responder
# - xterm / dbus-x11 / x11-utils: minimal desktop tooling
# -----------------------------------------------------------------------------
RUN apt-get update && apt-get install -y --no-install-recommends \
tigervnc-standalone-server \
tigervnc-common \
fluxbox \
xterm \
x11-utils \
x11-xserver-utils \
dbus-x11 \
novnc \
websockify \
python3 \
python3-numpy \
socat \
procps \
net-tools \
ca-certificates \
curl \
sudo \
nano \
&& rm -rf /var/lib/apt/lists/*
# -----------------------------------------------------------------------------
# Non-root user (HF Spaces best practice)
# -----------------------------------------------------------------------------
RUN useradd -m -u 1000 -s /bin/bash user && \
echo "user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# -----------------------------------------------------------------------------
# noVNC web assets — expose at a stable path so websockify can serve them
# -----------------------------------------------------------------------------
RUN ln -sf /usr/share/novnc /novnc && \
ln -sf /usr/share/novnc/vnc.html /usr/share/novnc/index.html
# -----------------------------------------------------------------------------
# Fluxbox autostart hook — keep the WM lean (no menu daemons, no compositor)
# -----------------------------------------------------------------------------
RUN mkdir -p /home/user/.fluxbox && \
echo "xsetroot -solid '#1f2937'" > /home/user/.fluxbox/startup && \
echo "xterm -geometry 100x30+50+50 -fa 'Monospace' -fs 11 &" >> /home/user/.fluxbox/startup && \
echo "exec fluxbox" >> /home/user/.fluxbox/startup && \
chmod +x /home/user/.fluxbox/startup && \
chown -R user:user /home/user
# -----------------------------------------------------------------------------
# Entry-point script (engineering-hardened startup sequence)
# -----------------------------------------------------------------------------
COPY start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh && \
chown user:user /usr/local/bin/start.sh
# Make /tmp/.X11-unix writable by the unprivileged user (Xvnc needs this)
RUN mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
USER user
WORKDIR /home/user
EXPOSE 7860
CMD ["/usr/local/bin/start.sh"]