# Use an Ubuntu base image FROM ubuntu:22.04 # Set environment variable for non-interactive timezone selection ENV DEBIAN_FRONTEND=noninteractive ENV HF_HOME="/data/huggingface" ENV DISPLAY=:99 ENV TZ=Europe/London # Install necessary packages RUN apt-get update && apt-get install -y \ firefox \ xvfb \ x11vnc \ novnc \ supervisor \ fluxbox \ tzdata \ wget \ net-tools \ && ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \ dpkg-reconfigure --frontend noninteractive tzdata && \ apt-get clean # Create the Hugging Face working directory and configure permissions RUN mkdir -p $HF_HOME/noVNC && \ chown -R 1000:1000 $HF_HOME # Install noVNC and websockify, placing them in the HF allowed directory RUN wget https://github.com/novnc/noVNC/archive/refs/tags/v1.3.0.tar.gz -O /noVNC.tar.gz && \ tar -xzf /noVNC.tar.gz && \ mv noVNC-1.3.0 $HF_HOME/noVNC && \ ln -s $HF_HOME/noVNC/utils/websockify /usr/local/bin/websockify # Copy supervisor configuration to the HF directory COPY supervisord.conf $HF_HOME/supervisord.conf # Use a non-root user for security USER 1000 # Expose only one port for Hugging Face Spaces EXPOSE 7860 # Set working directory for Hugging Face Spaces WORKDIR $HF_HOME # Command to start Supervisor using the config located in the HF allowed directory CMD ["/usr/bin/supervisord", "-c", "/data/huggingface/supervisord.conf"]