File size: 1,715 Bytes
be5a348
 
 
 
 
 
 
 
 
 
e26819d
be5a348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e26819d
 
 
 
 
 
 
 
 
 
be5a348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
# Use Ubuntu 22.04 as the base image for compatibility and minimal size
FROM ubuntu:22.04

# Set environment variables for non-interactive installation
ENV DEBIAN_FRONTEND=noninteractive
ENV USER=appuser
ENV HOME=/home/$USER
ENV DISPLAY=:1
ENV VNC_PORT=5901
ENV NOVNC_PORT=7860
ENV X11VNC_LOG=/tmp/x11vnc.log

# Install dependencies: Chrome, Xvfb, noVNC, Fluxbox, and utilities
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    xvfb \
    fluxbox \
    x11vnc \
    novnc \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Install Google Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
    && apt-get update \
    && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

# Create a non-root user
RUN useradd -m -s /bin/bash $USER

# Fix permissions for X11 socket directory
RUN mkdir -p /tmp/.X11-unix \
    && chmod 1777 /tmp/.X11-unix \
    && chown $USER:$USER /tmp/.X11-unix

# Create a minimal Fluxbox config to suppress warnings
RUN mkdir -p $HOME/.fluxbox
COPY fluxbox_menu $HOME/.fluxbox/menu
RUN chown -R $USER:$USER $HOME/.fluxbox

# Set up noVNC web interface
RUN ln -s /usr/share/novnc/vnc.html /usr/share/novnc/index.html

# Copy a startup script to run Chrome in VNC
RUN mkdir -p $HOME/scripts
COPY start.sh $HOME/scripts/start.sh
RUN chmod +x $HOME/scripts/start.sh

# Switch to non-root user
USER $USER
WORKDIR $HOME

# Expose port 7860 for noVNC (Hugging Face Spaces default)
EXPOSE $NOVNC_PORT

# Start the VNC server, noVNC, and Chrome
CMD ["/home/appuser/scripts/start.sh"]