chipling commited on
Commit
6b65116
·
verified ·
1 Parent(s): 05bbd13

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -8
Dockerfile CHANGED
@@ -1,10 +1,12 @@
1
- # Use the latest supported python slim image (Debian Bookworm)
2
  FROM python:3.9-slim
3
 
4
  # 1. Install system dependencies
5
  # We suppress prompts to avoid build errors
6
  ENV DEBIAN_FRONTEND=noninteractive
7
 
 
 
8
  RUN apt-get update && apt-get install -y \
9
  xfce4 \
10
  xfce4-terminal \
@@ -12,13 +14,13 @@ RUN apt-get update && apt-get install -y \
12
  x11vnc \
13
  novnc \
14
  websockify \
15
- numpy \
16
  firefox-esr \
17
  sudo \
18
  curl \
19
  git \
20
  vim \
21
  procps \
 
22
  && rm -rf /var/lib/apt/lists/*
23
 
24
  # 2. Setup a non-root user (Hugging Face Spaces defaults to UID 1000)
@@ -31,14 +33,18 @@ ENV HOME=/home/user \
31
  PATH=/home/user/.local/bin:$PATH
32
  WORKDIR $HOME
33
 
34
- # 4. Create the start script
35
- # We write the script directly here to avoid permission issues with COPY
 
 
 
36
  RUN echo '#!/bin/bash\n\
37
  \n\
38
- # Set VNC password\n\
39
  export VNC_PASSWD=${VNC_PASSWD:-password}\n\
40
  \n\
41
  # Start Xvfb (Virtual Monitor)\n\
 
42
  Xvfb :1 -screen 0 1280x720x16 &\n\
43
  export DISPLAY=:1\n\
44
  sleep 2\n\
@@ -53,14 +59,15 @@ x11vnc -storepasswd "$VNC_PASSWD" ~/.vnc/passwd\n\
53
  x11vnc -display :1 -rfbauth ~/.vnc/passwd -forever -shared -bg\n\
54
  \n\
55
  # Start NoVNC (The Web Interface)\n\
56
- # In Debian Bookworm, novnc is located at /usr/share/novnc\n\
 
57
  websockify --web /usr/share/novnc/ 7860 localhost:5900\n\
58
  ' > start.sh
59
 
60
  RUN chmod +x start.sh
61
 
62
- # 5. Expose the Hugging Face port
63
  EXPOSE 7860
64
 
65
- # 6. Run the start script
66
  CMD ["./start.sh"]
 
1
+ # Use the latest supported python slim image
2
  FROM python:3.9-slim
3
 
4
  # 1. Install system dependencies
5
  # We suppress prompts to avoid build errors
6
  ENV DEBIAN_FRONTEND=noninteractive
7
 
8
+ # Note: Removed 'numpy' from this list.
9
+ # Added 'dbus-x11' which is often needed for XFCE to start correctly in containers.
10
  RUN apt-get update && apt-get install -y \
11
  xfce4 \
12
  xfce4-terminal \
 
14
  x11vnc \
15
  novnc \
16
  websockify \
 
17
  firefox-esr \
18
  sudo \
19
  curl \
20
  git \
21
  vim \
22
  procps \
23
+ dbus-x11 \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
  # 2. Setup a non-root user (Hugging Face Spaces defaults to UID 1000)
 
33
  PATH=/home/user/.local/bin:$PATH
34
  WORKDIR $HOME
35
 
36
+ # 4. Install Python dependencies (Numpy goes here!)
37
+ RUN pip install --no-cache-dir numpy
38
+
39
+ # 5. Create the start script
40
+ # We configure the VNC and NoVNC connection here
41
  RUN echo '#!/bin/bash\n\
42
  \n\
43
+ # Set VNC password (default: password)\n\
44
  export VNC_PASSWD=${VNC_PASSWD:-password}\n\
45
  \n\
46
  # Start Xvfb (Virtual Monitor)\n\
47
+ # 1280x720 is a good standard size\n\
48
  Xvfb :1 -screen 0 1280x720x16 &\n\
49
  export DISPLAY=:1\n\
50
  sleep 2\n\
 
59
  x11vnc -display :1 -rfbauth ~/.vnc/passwd -forever -shared -bg\n\
60
  \n\
61
  # Start NoVNC (The Web Interface)\n\
62
+ # This bridges the VNC server (5900) to the Web Port (7860)\n\
63
+ echo "Starting NoVNC..."\n\
64
  websockify --web /usr/share/novnc/ 7860 localhost:5900\n\
65
  ' > start.sh
66
 
67
  RUN chmod +x start.sh
68
 
69
+ # 6. Expose the Hugging Face port
70
  EXPOSE 7860
71
 
72
+ # 7. Run the start script
73
  CMD ["./start.sh"]