File size: 1,878 Bytes
be5a348
 
 
 
 
 
 
 
 
 
e26819d
be5a348
13e0016
be5a348
 
 
13e0016
 
be5a348
 
 
 
 
 
13e0016
 
 
be5a348
13e0016
be5a348
 
 
 
 
e26819d
 
 
 
 
 
 
 
 
 
be5a348
 
 
13e0016
be5a348
 
 
 
 
 
 
 
 
 
 
13e0016
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
61
# 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: Brave prerequisites, Xvfb, noVNC, Fluxbox, and utilities
RUN apt-get update && apt-get install -y \
    wget \
    gnupg \
    curl \
    apt-transport-https \
    xvfb \
    fluxbox \
    x11vnc \
    novnc \
    && rm -rf /var/lib/apt/lists/*

# Install Brave Browser
RUN curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg \
    && echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" > /etc/apt/sources.list.d/brave-browser-release.list \
    && apt-get update \
    && apt-get install -y brave-browser \
    && 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 Brave 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 Brave
CMD ["/home/appuser/scripts/start.sh"]