File size: 1,465 Bytes
068f4df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84a1cf7
068f4df
 
 
 
 
 
 
 
84a1cf7
068f4df
84a1cf7
 
068f4df
 
 
 
 
84a1cf7
 
068f4df
 
 
 
84a1cf7
068f4df
 
84a1cf7
 
068f4df
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
FROM ubuntu:22.04

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# 1. Install Ubuntu basics, Python, and Chrome dependencies
RUN apt-get update && apt-get install -y \
    python3 \
    python3-pip \
    wget \
    curl \
    unzip \
    xvfb \
    libnss3 \
    libgbm1 \
    libasound2 \
    sudo \
    ttyd \
    gnupg \
    && apt-get clean

# 2. 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

# 3. Create a user for Hugging Face (UID 1000)
# FIXED: Changed /etc/etc/sudoers to /etc/sudoers
RUN useradd -m -u 1000 user && \
    echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app

# 4. Setup the "Binary Hijack" script
# This ensures Chrome always runs with the necessary VPS flags
RUN mkdir -p $HOME/.local/bin && \
    echo '#!/bin/bash\n/usr/bin/google-chrome-stable --no-sandbox --headless --disable-dev-shm-usage --disable-gpu "$@"' > $HOME/.local/bin/google-chrome && \
    chmod +x $HOME/.local/bin/google-chrome

# 5. Hugging Face uses port 7860
EXPOSE 7860

# 6. Start the web terminal
# This keeps the Space alive and gives you a terminal in your browser
CMD ["ttyd", "-p", "7860", "bash"]