aaa / Dockerfile
vish85521's picture
Create Dockerfile
77ccb7a verified
FROM alpine:edge
# 1. Install desktop, VNC, and utilities
RUN apk update && apk add --no-cache \
bash \
xfce4 \
xfce4-terminal \
x11vnc \
xvfb \
novnc \
websockify \
wget \
curl \
git \
dbus-x11 \
adwaita-icon-theme \
ttf-dejavu \
xrdb
# 2. Fix permissions for X11/ICE sockets
RUN mkdir -p /tmp/.X11-unix /tmp/.ICE-unix && \
chmod 1777 /tmp/.X11-unix /tmp/.ICE-unix
# 3. Delete the XFCE power manager autostart
RUN rm -f /etc/xdg/autostart/xfce4-power-manager.desktop
# 4. Create a non-root user
RUN adduser -D -u 1000 user
ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
# 5. Bulletproof Health Check & Heartbeat Fix
# Create the index.html redirect for HF health checks
RUN echo '<meta http-equiv="refresh" content="0; url=vnc.html">' > /usr/share/novnc/index.html
# Inject the JavaScript heartbeat into the VNC page so HF doesn't pause while in use
RUN sed -i '/<\/head>/i \ <script>\n setInterval(function() {\n fetch("/");\n }, 60000);\n </script>' /usr/share/novnc/vnc.html
WORKDIR $HOME
# 6. Set VNC password and fix permissions
RUN mkdir -p $HOME/.vnc && \
x11vnc -storepasswd 1234 $HOME/.vnc/passwd && \
chown -R user:user $HOME
# 7. Switch to the Hugging Face required user
USER user
# 8. Expose web port
EXPOSE 7860
# 9. Start everything
CMD bash -c "\
Xvfb :0 -screen 0 1024x768x24 & \
sleep 2 ; \
export DISPLAY=:0 ; \
dbus-launch startxfce4 & \
x11vnc -display :0 -rfbauth $HOME/.vnc/passwd -forever -rfbport 5900 & \
websockify --web=/usr/share/novnc/ 7860 127.0.0.1:5900 \
"