# Use Ubuntu 22.04 as the base image for compatibility and minimal size FROM ubuntu:22.04 # Set environment variables for non-interactive installation ENV DEBIAN_FRONTEND=noninteractive ENV USER=appuser ENV HOME=/home/$USER ENV DISPLAY=:1 ENV VNC_PORT=5901 ENV NOVNC_PORT=7860 ENV X11VNC_LOG=/tmp/x11vnc.log # Install dependencies: Chrome, Xvfb, noVNC, Fluxbox, and utilities RUN apt-get update && apt-get install -y \ wget \ gnupg \ xvfb \ fluxbox \ x11vnc \ novnc \ curl \ && rm -rf /var/lib/apt/lists/* # Install Google Chrome RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \ && apt-get update \ && apt-get install -y google-chrome-stable \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -s /bin/bash $USER # Fix permissions for X11 socket directory RUN mkdir -p /tmp/.X11-unix \ && chmod 1777 /tmp/.X11-unix \ && chown $USER:$USER /tmp/.X11-unix # Create a minimal Fluxbox config to suppress warnings RUN mkdir -p $HOME/.fluxbox COPY fluxbox_menu $HOME/.fluxbox/menu RUN chown -R $USER:$USER $HOME/.fluxbox # Set up noVNC web interface RUN ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html # Copy a startup script to run Chrome in VNC RUN mkdir -p $HOME/scripts COPY start.sh $HOME/scripts/start.sh RUN chmod +x $HOME/scripts/start.sh # Switch to non-root user USER $USER WORKDIR $HOME # Expose port 7860 for noVNC (Hugging Face Spaces default) EXPOSE $NOVNC_PORT # Start the VNC server, noVNC, and Chrome CMD ["/home/appuser/scripts/start.sh"]