File size: 1,417 Bytes
c93add6
 
 
c5e70e1
 
5b0c091
 
c5e70e1
 
5b0c091
 
c93add6
 
 
 
 
 
c5e70e1
c93add6
 
c5e70e1
 
 
565d157
5b0c091
 
 
 
c93add6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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"]