Yuvan666 commited on
Commit
a65c2f7
·
1 Parent(s): 583face

fix: cloudflared install verification, noVNC on port 7860 for tunnel

Browse files
Files changed (2) hide show
  1. Dockerfile +8 -29
  2. supervisord.conf +10 -19
Dockerfile CHANGED
@@ -1,13 +1,5 @@
1
  # =============================================================================
2
  # ALTYZEN Stealth Browser Stack - Cloudflare Tunnel Edition
3
- # Hugging Face Docker Space with Private VNC Access
4
- # =============================================================================
5
- # Architecture:
6
- # [Playwright Browser] --> [Xvfb :99] --> [x11vnc] --> [noVNC :7860]
7
- # |
8
- # [cloudflared tunnel]
9
- # |
10
- # [agent.yourdomain.com]
11
  # =============================================================================
12
 
13
  FROM python:3.11-slim
@@ -17,23 +9,16 @@ ENV DISPLAY=:99
17
 
18
  # Install system dependencies
19
  RUN apt-get update && apt-get install -y --no-install-recommends \
20
- # Virtual Display
21
  xvfb \
22
- # Window Manager
23
  fluxbox \
24
- # VNC Server
25
  x11vnc \
26
- # WebSocket proxy
27
  websockify \
28
- # Process Manager
29
  supervisor \
30
- # Networking
31
  net-tools \
32
  curl \
33
  wget \
34
  git \
35
- gnupg \
36
- # Browser dependencies
37
  libnss3 \
38
  libnspr4 \
39
  libatk1.0-0 \
@@ -55,9 +40,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
55
  fonts-noto-color-emoji \
56
  && rm -rf /var/lib/apt/lists/*
57
 
58
- # Install cloudflared (Cloudflare Tunnel)
59
- RUN curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /usr/local/bin/cloudflared && \
60
- chmod +x /usr/local/bin/cloudflared
 
 
61
 
62
  # Install noVNC from GitHub
63
  RUN git clone --depth 1 https://github.com/novnc/noVNC.git /opt/novnc && \
@@ -66,31 +53,23 @@ RUN git clone --depth 1 https://github.com/novnc/noVNC.git /opt/novnc && \
66
 
67
  WORKDIR /app
68
 
69
- # Copy requirements first
70
  COPY requirements.txt .
71
  RUN pip install --no-cache-dir --upgrade pip && \
72
  pip install --no-cache-dir -r requirements.txt
73
 
74
- # Install Playwright browsers
75
  RUN playwright install chromium --with-deps
76
 
77
- # Copy application files
78
  COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
79
  COPY app.py .
80
  COPY agent.py .
81
 
82
- # Create necessary directories
83
  RUN mkdir -p /var/log/supervisor /var/run /root/.fluxbox
84
-
85
- # Configure fluxbox (minimal)
86
  RUN echo "session.screen0.toolbar.visible: false" > /root/.fluxbox/init
87
 
88
- # Expose port 7860 for HuggingFace (also used by noVNC internally)
89
  EXPOSE 7860
90
 
91
- # Health check - just ensure supervisord is running
92
  HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
93
- CMD pgrep supervisord > /dev/null || exit 1
94
 
95
- # Start supervisord
96
  CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
 
1
  # =============================================================================
2
  # ALTYZEN Stealth Browser Stack - Cloudflare Tunnel Edition
 
 
 
 
 
 
 
 
3
  # =============================================================================
4
 
5
  FROM python:3.11-slim
 
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
12
  xvfb \
 
13
  fluxbox \
 
14
  x11vnc \
 
15
  websockify \
 
16
  supervisor \
 
17
  net-tools \
18
  curl \
19
  wget \
20
  git \
21
+ ca-certificates \
 
22
  libnss3 \
23
  libnspr4 \
24
  libatk1.0-0 \
 
40
  fonts-noto-color-emoji \
41
  && rm -rf /var/lib/apt/lists/*
42
 
43
+ # Install cloudflared - download with verification
44
+ RUN curl -L --output /usr/local/bin/cloudflared \
45
+ https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && \
46
+ chmod +x /usr/local/bin/cloudflared && \
47
+ /usr/local/bin/cloudflared --version
48
 
49
  # Install noVNC from GitHub
50
  RUN git clone --depth 1 https://github.com/novnc/noVNC.git /opt/novnc && \
 
53
 
54
  WORKDIR /app
55
 
 
56
  COPY requirements.txt .
57
  RUN pip install --no-cache-dir --upgrade pip && \
58
  pip install --no-cache-dir -r requirements.txt
59
 
60
+ # Install Playwright
61
  RUN playwright install chromium --with-deps
62
 
 
63
  COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
64
  COPY app.py .
65
  COPY agent.py .
66
 
 
67
  RUN mkdir -p /var/log/supervisor /var/run /root/.fluxbox
 
 
68
  RUN echo "session.screen0.toolbar.visible: false" > /root/.fluxbox/init
69
 
 
70
  EXPOSE 7860
71
 
 
72
  HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
73
+ CMD curl -f http://localhost:7860/ || exit 1
74
 
 
75
  CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
supervisord.conf CHANGED
@@ -1,6 +1,6 @@
1
  ; =============================================================================
2
- ; Supervisord - Stealth Browser Stack with Cloudflare Tunnel
3
- ; Manages: Xvfb, Fluxbox, x11vnc, noVNC, Cloudflare Tunnel, Python Agent
4
  ; =============================================================================
5
 
6
  [supervisord]
@@ -11,7 +11,7 @@ childlogdir=/var/log/supervisor
11
  user=root
12
 
13
  ; =============================================================================
14
- ; Process 1: Xvfb - Virtual Framebuffer (Creates display :99)
15
  ; =============================================================================
16
  [program:xvfb]
17
  command=/usr/bin/Xvfb :99 -screen 0 1280x720x24 -ac +extension GLX +render -noreset
@@ -31,7 +31,7 @@ stdout_logfile=/var/log/supervisor/fluxbox.log
31
  stderr_logfile=/var/log/supervisor/fluxbox_err.log
32
 
33
  ; =============================================================================
34
- ; Process 3: x11vnc - VNC Server (streams :99 to port 5900)
35
  ; =============================================================================
36
  [program:x11vnc]
37
  command=/bin/bash -c "sleep 3 && /usr/bin/x11vnc -display :99 -forever -shared -nopw -rfbport 5900 -xkb"
@@ -41,18 +41,18 @@ stdout_logfile=/var/log/supervisor/x11vnc.log
41
  stderr_logfile=/var/log/supervisor/x11vnc_err.log
42
 
43
  ; =============================================================================
44
- ; Process 4: noVNC - HTML5 VNC Client on internal port 6080
45
  ; =============================================================================
46
  [program:novnc]
47
- command=/bin/bash -c "sleep 5 && /opt/novnc/utils/novnc_proxy --vnc localhost:5900 --listen 6080 --web /opt/novnc"
48
  autorestart=true
49
  priority=400
50
  stdout_logfile=/var/log/supervisor/novnc.log
51
  stderr_logfile=/var/log/supervisor/novnc_err.log
52
 
53
  ; =============================================================================
54
- ; Process 5: Cloudflare Tunnel - Exposes noVNC via private subdomain
55
- ; Token is passed via environment variable CLOUDFLARE_TUNNEL_TOKEN
56
  ; =============================================================================
57
  [program:cloudflared]
58
  command=/bin/bash -c "sleep 8 && /usr/local/bin/cloudflared tunnel --no-autoupdate run --token %(ENV_CLOUDFLARE_TUNNEL_TOKEN)s"
@@ -62,24 +62,15 @@ stdout_logfile=/var/log/supervisor/cloudflared.log
62
  stderr_logfile=/var/log/supervisor/cloudflared_err.log
63
 
64
  ; =============================================================================
65
- ; Process 6: Python Agent - Browser automation on display :99
66
  ; =============================================================================
67
  [program:agent]
68
  command=/bin/bash -c "sleep 12 && DISPLAY=:99 python /app/app.py"
69
  directory=/app
 
70
  autorestart=true
71
  priority=500
72
  startretries=10
73
  startsecs=15
74
  stdout_logfile=/var/log/supervisor/agent.log
75
  stderr_logfile=/var/log/supervisor/agent_err.log
76
-
77
- ; =============================================================================
78
- ; Process 7: Dummy HTTP Server on 7860 (Keeps HF Space "Running")
79
- ; =============================================================================
80
- [program:dummy_server]
81
- command=/bin/bash -c "sleep 3 && python -m http.server 7860 --directory /opt/novnc"
82
- autorestart=true
83
- priority=350
84
- stdout_logfile=/var/log/supervisor/dummy_server.log
85
- stderr_logfile=/var/log/supervisor/dummy_server_err.log
 
1
  ; =============================================================================
2
+ ; Supervisord - Stealth Browser Stack
3
+ ; noVNC on 7860, Cloudflare Tunnel bridges to public hostname
4
  ; =============================================================================
5
 
6
  [supervisord]
 
11
  user=root
12
 
13
  ; =============================================================================
14
+ ; Process 1: Xvfb - Virtual Display :99
15
  ; =============================================================================
16
  [program:xvfb]
17
  command=/usr/bin/Xvfb :99 -screen 0 1280x720x24 -ac +extension GLX +render -noreset
 
31
  stderr_logfile=/var/log/supervisor/fluxbox_err.log
32
 
33
  ; =============================================================================
34
+ ; Process 3: x11vnc - VNC Server on port 5900
35
  ; =============================================================================
36
  [program:x11vnc]
37
  command=/bin/bash -c "sleep 3 && /usr/bin/x11vnc -display :99 -forever -shared -nopw -rfbport 5900 -xkb"
 
41
  stderr_logfile=/var/log/supervisor/x11vnc_err.log
42
 
43
  ; =============================================================================
44
+ ; Process 4: noVNC - HTML5 VNC Client on PORT 7860 (HF requires this)
45
  ; =============================================================================
46
  [program:novnc]
47
+ command=/bin/bash -c "sleep 5 && /opt/novnc/utils/novnc_proxy --vnc localhost:5900 --listen 7860 --web /opt/novnc"
48
  autorestart=true
49
  priority=400
50
  stdout_logfile=/var/log/supervisor/novnc.log
51
  stderr_logfile=/var/log/supervisor/novnc_err.log
52
 
53
  ; =============================================================================
54
+ ; Process 5: Cloudflare Tunnel - Bridges localhost:7860 to public hostname
55
+ ; Token from environment variable CLOUDFLARE_TUNNEL_TOKEN
56
  ; =============================================================================
57
  [program:cloudflared]
58
  command=/bin/bash -c "sleep 8 && /usr/local/bin/cloudflared tunnel --no-autoupdate run --token %(ENV_CLOUDFLARE_TUNNEL_TOKEN)s"
 
62
  stderr_logfile=/var/log/supervisor/cloudflared_err.log
63
 
64
  ; =============================================================================
65
+ ; Process 6: Python Agent - Browser automation
66
  ; =============================================================================
67
  [program:agent]
68
  command=/bin/bash -c "sleep 12 && DISPLAY=:99 python /app/app.py"
69
  directory=/app
70
+ environment=DISPLAY=":99"
71
  autorestart=true
72
  priority=500
73
  startretries=10
74
  startsecs=15
75
  stdout_logfile=/var/log/supervisor/agent.log
76
  stderr_logfile=/var/log/supervisor/agent_err.log