void0028 commited on
Commit
e5a5cdb
Β·
verified Β·
1 Parent(s): 0586347

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +98 -29
Dockerfile CHANGED
@@ -2,23 +2,21 @@ FROM node:18-bullseye-slim
2
 
3
  USER root
4
 
5
- # 1. Install System Dependencies
6
- # We install ffmpeg (for the engine) and dumb-init (to handle processes properly)
7
  RUN apt-get update && \
8
- apt-get install -y wget ffmpeg dumb-init && \
9
  apt-get autoremove -y && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
- # 2. Setup Directories
13
  WORKDIR /stremio
14
- # Fix the ENOENT error by pre-creating the config folder
15
  RUN mkdir -p /root/.stremio-server
16
 
17
- # 3. Download Stremio Engine
18
  RUN wget https://dl.strem.io/four/v4.4.168/server.js -O server.js
19
  RUN wget https://dl.strem.io/four/v4.4.168/stremio.asar -O stremio.asar
20
 
21
- # 4. Install Proxy Dependency
22
  RUN npm install http-proxy
23
 
24
  # 5. Environment Variables
@@ -27,49 +25,120 @@ ENV CASTING_DISABLED=1
27
  ENV STREAMING_DISABLED=0
28
  ENV PORT=11470
29
 
30
- # 6. Create the Proxy Script (The Interface)
31
- # I added extra logging here so you SEE it start.
32
  RUN echo "const http = require('http'); \
33
  const httpProxy = require('http-proxy'); \
34
- const proxy = httpProxy.createProxyServer({}); \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  const STREMIO_TARGET = 'http://127.0.0.1:11470'; \
36
  \
37
- proxy.on('error', function (err, req, res) { \
38
- console.error('Proxy Error:', err.message); \
39
- res.writeHead(500, { 'Content-Type': 'text/plain' }); \
40
- res.end('Proxy Error: Stremio is booting...'); \
 
41
  }); \
42
  \
43
  const server = http.createServer((req, res) => { \
44
  if (req.url === '/' || req.url === '/health') { \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  res.writeHead(200, { 'Content-Type': 'text/html' }); \
46
- res.end('<body style=\"background:black;color:#00ff00;font-family:monospace;display:flex;align-items:center;justify-content:center;height:100vh;\"><h1>βœ… STREMIO IS LIVE<br><span style=\"color:white;font-size:12px\">FFMPEG: Detected | Engine: Running</span></h1></body>'); \
47
  } else { \
48
  proxy.web(req, res, { target: STREMIO_TARGET }); \
49
  } \
50
  }); \
51
  \
52
  server.listen(7860, '0.0.0.0', () => { \
53
- console.log('----------------------------------------'); \
54
- console.log('βœ… PROXY STARTED ON PORT 7860'); \
55
- console.log('πŸ‘‰ WAITING FOR STREMIO ENGINE...'); \
56
- console.log('----------------------------------------'); \
57
  });" > /stremio/proxy.js
58
 
59
- # 7. Create a Robust Startup Script
60
- # This prints status messages so you don't feel lost.
61
  RUN echo "#!/bin/bash \n\
62
  node /stremio/proxy.js & \n\
63
- PID_PROXY=\$! \n\
64
  sleep 2 \n\
65
- echo 'πŸš€ STARTING STREMIO ENGINE...' \n\
66
- node /stremio/server.js & \n\
67
- PID_SERVER=\$! \n\
68
- wait \$PID_SERVER" > /stremio/start.sh && chmod +x /stremio/start.sh
69
 
70
- # 8. Expose Port
71
  EXPOSE 7860
72
-
73
- # 9. Run with dumb-init (prevents zombie processes)
74
  ENTRYPOINT ["/usr/bin/dumb-init", "--"]
75
  CMD ["/stremio/start.sh"]
 
2
 
3
  USER root
4
 
5
+ # 1. Install System Tools
 
6
  RUN apt-get update && \
7
+ apt-get install -y wget ffmpeg dumb-init procps && \
8
  apt-get autoremove -y && \
9
  rm -rf /var/lib/apt/lists/*
10
 
11
+ # 2. Setup Stremio
12
  WORKDIR /stremio
 
13
  RUN mkdir -p /root/.stremio-server
14
 
15
+ # 3. Download Engine
16
  RUN wget https://dl.strem.io/four/v4.4.168/server.js -O server.js
17
  RUN wget https://dl.strem.io/four/v4.4.168/stremio.asar -O stremio.asar
18
 
19
+ # 4. Install Proxy
20
  RUN npm install http-proxy
21
 
22
  # 5. Environment Variables
 
25
  ENV STREAMING_DISABLED=0
26
  ENV PORT=11470
27
 
28
+ # 6. DASHBOARD V2 (With Speedometer)
 
29
  RUN echo "const http = require('http'); \
30
  const httpProxy = require('http-proxy'); \
31
+ const { execSync } = require('child_process'); \
32
+ const os = require('os'); \
33
+ const fs = require('fs'); \
34
+ \
35
+ // --- STATS ENGINE --- \
36
+ let stats = { \
37
+ current: 0, \
38
+ max: 0, \
39
+ min: 0, \
40
+ avg: 0, \
41
+ totalBytes: 0, \
42
+ samples: 0, \
43
+ startTime: Date.now() \
44
+ }; \
45
+ \
46
+ let lastRx = 0; \
47
+ try { lastRx = parseInt(fs.readFileSync('/sys/class/net/eth0/statistics/rx_bytes', 'utf8')); } catch(e) {} \
48
+ \
49
+ // Update Stats every second \
50
+ setInterval(() => { \
51
+ try { \
52
+ const currRx = parseInt(fs.readFileSync('/sys/class/net/eth0/statistics/rx_bytes', 'utf8')); \
53
+ const diff = currRx - lastRx; \
54
+ lastRx = currRx; \
55
+ \
56
+ // Convert bytes/sec to Mbps \
57
+ const mbps = (diff * 8) / (1000 * 1000); \
58
+ stats.current = mbps; \
59
+ \
60
+ // Update Max \
61
+ if (mbps > stats.max) stats.max = mbps; \
62
+ \
63
+ // Update Min (Only count non-idle speeds > 0.1 Mbps) \
64
+ if (mbps > 0.1) { \
65
+ if (stats.min === 0 || mbps < stats.min) stats.min = mbps; \
66
+ } \
67
+ \
68
+ // Update Avg \
69
+ stats.totalBytes += diff; \
70
+ stats.samples++; \
71
+ // Avg = (Total Bits) / (Total Seconds) / 1M \
72
+ stats.avg = (stats.totalBytes * 8) / stats.samples / 1000000; \
73
+ \
74
+ } catch(e) {} \
75
+ }, 1000); \
76
+ \
77
+ // --- PROXY SERVER --- \
78
+ const proxy = httpProxy.createProxyServer({ changeOrigin: true, xfwd: true }); \
79
  const STREMIO_TARGET = 'http://127.0.0.1:11470'; \
80
  \
81
+ proxy.on('error', (err, req, res) => { \
82
+ if (!res.headersSent) { \
83
+ res.writeHead(500, { 'Content-Type': 'text/plain' }); \
84
+ res.end('Proxy Error'); \
85
+ } \
86
  }); \
87
  \
88
  const server = http.createServer((req, res) => { \
89
  if (req.url === '/' || req.url === '/health') { \
90
+ let disk = 'Unknown', ram = 'Unknown', uptime = 'Unknown'; \
91
+ try { \
92
+ disk = execSync(\"df -h / | tail -1 | awk '{print \$3 \\\" / \\\" \$2}'\").toString().trim(); \
93
+ ram = execSync(\"free -m | grep Mem | awk '{print \$3 \\\"MB / \\\" \$2 \\\"MB\\\"}'\").toString().trim(); \
94
+ const upSec = os.uptime(); \
95
+ uptime = Math.floor(upSec / 3600) + 'h ' + Math.floor((upSec % 3600) / 60) + 'm'; \
96
+ } catch (e) {} \
97
+ \
98
+ const duration = ((Date.now() - stats.startTime) / 1000 / 60 / 60).toFixed(1); \
99
+ \
100
+ const html = \` \
101
+ <body style='background:#0d1117; color:#3fb950; font-family:monospace; display:flex; flex-direction:column; align-items:center; justify-content:center; height:100vh; margin:0;'> \
102
+ <div style='border: 1px solid #3fb950; padding: 25px; border-radius: 12px; min-width: 300px; box-shadow: 0 0 20px rgba(63, 185, 80, 0.2); background:#161b22;'> \
103
+ <h2 style='margin:0 0 15px 0; text-align:center; border-bottom: 1px solid #30363d; padding-bottom:10px;'>πŸš€ NETWORK METRICS</h2> \
104
+ \
105
+ <div style='margin-bottom: 20px;'> \
106
+ <div style='font-size: 24px; color:white; text-align:center; margin-bottom:5px;'>⬇️ \${stats.current.toFixed(2)} Mbps</div> \
107
+ <div style='text-align:center; font-size:12px; color:#8b949e;'>Live Throughput</div> \
108
+ </div> \
109
+ \
110
+ <div style='display:grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 13px; color:#c9d1d9; border-top: 1px solid #30363d; padding-top:15px;'> \
111
+ <div>πŸ“ˆ Max: <span style='color:#white'>\${stats.max.toFixed(2)}</span> Mbps</div> \
112
+ <div>πŸ“‰ Min (Act): <span style='color:#white'>\${stats.min.toFixed(2)}</span> Mbps</div> \
113
+ <div>πŸ“Š Avg: <span style='color:#white'>\${stats.avg.toFixed(2)}</span> Mbps</div> \
114
+ <div>⏱️ Monitored: <span style='color:#white'>\${duration}</span> Hrs</div> \
115
+ </div> \
116
+ \
117
+ <div style='margin-top: 20px; border-top: 1px solid #30363d; padding-top: 15px; font-size: 12px; color:#8b949e;'> \
118
+ <p>πŸ’Ύ Disk: \${disk}</p> \
119
+ <p>🧠 RAM: \${ram}</p> \
120
+ <p>⚑ Uptime: \${uptime}</p> \
121
+ </div> \
122
+ </div> \
123
+ <script>setTimeout(() => location.reload(), 2000);</script> \
124
+ </body>\`; \
125
  res.writeHead(200, { 'Content-Type': 'text/html' }); \
126
+ res.end(html); \
127
  } else { \
128
  proxy.web(req, res, { target: STREMIO_TARGET }); \
129
  } \
130
  }); \
131
  \
132
  server.listen(7860, '0.0.0.0', () => { \
133
+ console.log('βœ… DASHBOARD V2 LIVE'); \
 
 
 
134
  });" > /stremio/proxy.js
135
 
136
+ # 7. Startup Script
 
137
  RUN echo "#!/bin/bash \n\
138
  node /stremio/proxy.js & \n\
 
139
  sleep 2 \n\
140
+ node /stremio/server.js" > /stremio/start.sh && chmod +x /stremio/start.sh
 
 
 
141
 
 
142
  EXPOSE 7860
 
 
143
  ENTRYPOINT ["/usr/bin/dumb-init", "--"]
144
  CMD ["/stremio/start.sh"]