Create Dockerfile
Browse files- Dockerfile +60 -0
Dockerfile
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM alpine:edge
|
| 2 |
+
|
| 3 |
+
# 1. Install desktop, VNC, and utilities
|
| 4 |
+
RUN apk update && apk add --no-cache \
|
| 5 |
+
bash \
|
| 6 |
+
xfce4 \
|
| 7 |
+
xfce4-terminal \
|
| 8 |
+
x11vnc \
|
| 9 |
+
xvfb \
|
| 10 |
+
novnc \
|
| 11 |
+
websockify \
|
| 12 |
+
wget \
|
| 13 |
+
curl \
|
| 14 |
+
git \
|
| 15 |
+
dbus-x11 \
|
| 16 |
+
adwaita-icon-theme \
|
| 17 |
+
ttf-dejavu \
|
| 18 |
+
xrdb
|
| 19 |
+
|
| 20 |
+
# 2. Fix permissions for X11/ICE sockets
|
| 21 |
+
RUN mkdir -p /tmp/.X11-unix /tmp/.ICE-unix && \
|
| 22 |
+
chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
|
| 23 |
+
|
| 24 |
+
# 3. Delete the XFCE power manager autostart
|
| 25 |
+
RUN rm -f /etc/xdg/autostart/xfce4-power-manager.desktop
|
| 26 |
+
|
| 27 |
+
# 4. Create a non-root user
|
| 28 |
+
RUN adduser -D -u 1000 user
|
| 29 |
+
ENV HOME=/home/user
|
| 30 |
+
ENV PATH=/home/user/.local/bin:$PATH
|
| 31 |
+
|
| 32 |
+
# 5. Bulletproof Health Check & Heartbeat Fix
|
| 33 |
+
# Create the index.html redirect for HF health checks
|
| 34 |
+
RUN echo '<meta http-equiv="refresh" content="0; url=vnc.html">' > /usr/share/novnc/index.html
|
| 35 |
+
|
| 36 |
+
# Inject the JavaScript heartbeat into the VNC page so HF doesn't pause while in use
|
| 37 |
+
RUN sed -i '/<\/head>/i \ <script>\n setInterval(function() {\n fetch("/");\n }, 60000);\n </script>' /usr/share/novnc/vnc.html
|
| 38 |
+
|
| 39 |
+
WORKDIR $HOME
|
| 40 |
+
|
| 41 |
+
# 6. Set VNC password and fix permissions
|
| 42 |
+
RUN mkdir -p $HOME/.vnc && \
|
| 43 |
+
x11vnc -storepasswd 1234 $HOME/.vnc/passwd && \
|
| 44 |
+
chown -R user:user $HOME
|
| 45 |
+
|
| 46 |
+
# 7. Switch to the Hugging Face required user
|
| 47 |
+
USER user
|
| 48 |
+
|
| 49 |
+
# 8. Expose web port
|
| 50 |
+
EXPOSE 7860
|
| 51 |
+
|
| 52 |
+
# 9. Start everything
|
| 53 |
+
CMD bash -c "\
|
| 54 |
+
Xvfb :0 -screen 0 1024x768x24 & \
|
| 55 |
+
sleep 2 ; \
|
| 56 |
+
export DISPLAY=:0 ; \
|
| 57 |
+
dbus-launch startxfce4 & \
|
| 58 |
+
x11vnc -display :0 -rfbauth $HOME/.vnc/passwd -forever -rfbport 5900 & \
|
| 59 |
+
websockify --web=/usr/share/novnc/ 7860 127.0.0.1:5900 \
|
| 60 |
+
"
|