# Use an Ubuntu base image FROM ubuntu:22.04 # Set environment variables for Hugging Face compliance ENV HF_HOME="/data/huggingface" ENV DISPLAY=:99 ENV PORT=7860 # Set environment variable for non-interactive timezone selection ENV DEBIAN_FRONTEND=noninteractive # Install necessary packages RUN apt-get update && apt-get install -y \ firefox \ xvfb \ x11vnc \ novnc \ supervisor \ fluxbox \ python3-pip \ wget \ net-tools \ && rm -rf /var/lib/apt/lists/* # Install tzdata and configure timezone RUN apt-get update && \ apt-get install -y tzdata && \ ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime && \ dpkg-reconfigure --frontend noninteractive tzdata && \ apt-get clean # Install noVNC and websockify 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 /opt/noVNC && \ ln -s /opt/noVNC/utils/websockify /usr/local/bin/websockify # Create the Hugging Face working directory and configure permissions RUN mkdir -p $HF_HOME /config/log/firefox /opt/noVNC && \ chown -R 1000:1000 $HF_HOME /config/log/firefox /opt/noVNC # Copy the supervisor config to the HF allowed 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 $HF_HOME CMD ["/usr/bin/supervisord", "-c", "/data/huggingface/supervisord.conf"]