FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive # HF Spaces requirements ENV HF_HOME=/tmp/huggingface ENV GRADIO_SERVER_NAME=0.0.0.0 ENV GRADIO_SERVER_PORT=7860 # 1) Install Xfce, x11vnc, Xvfb, xdotool, etc. RUN apt-get update && apt-get install -y \ xfce4 \ xfce4-goodies \ x11vnc \ xvfb \ xdotool \ imagemagick \ x11-apps \ sudo \ software-properties-common \ python3 \ python3-pip \ curl \ wget \ scrot \ novnc \ websockify \ net-tools \ && apt-get remove -y light-locker xfce4-screensaver xfce4-power-manager || true \ && apt-get clean && rm -rf /var/lib/apt/lists/* # 2) Add the mozillateam PPA and install Firefox ESR RUN add-apt-repository ppa:mozillateam/ppa \ && apt-get update \ && apt-get install -y --no-install-recommends firefox-esr \ && update-alternatives --set x-www-browser /usr/bin/firefox-esr \ && apt-get clean && rm -rf /var/lib/apt/lists/* # 3) Create non-root user (HF Spaces requirement) RUN useradd -m -u 1000 user ENV HOME=/home/user WORKDIR /home/user/app # 4) Install Python dependencies COPY --chown=user requirements.txt . RUN pip3 install --no-cache-dir -r requirements.txt # 5) Copy application code COPY --chown=user . /home/user/app # 6) Setup noVNC for web-based VNC RUN ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html # 7) Make start script executable RUN chmod +x /home/user/app/start.sh USER user # Expose port 7860 for Gradio EXPOSE 7860 CMD ["/home/user/app/start.sh"]