File size: 1,612 Bytes
3f4039e 4419cf1 3f4039e 4419cf1 3f4039e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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"] |