harsh-dev commited on
Commit
3fef310
·
unverified ·
1 Parent(s): f61139e
Files changed (1) hide show
  1. Dockerfile +84 -16
Dockerfile CHANGED
@@ -2,27 +2,95 @@ FROM node:22-bookworm
2
 
3
  ENV NODE_ENV=production \
4
  HOME=/root \
5
- DSH_WORKSPACE=/data/research \
6
- PORT=7860
7
 
8
- RUN mkdir -p /data/research /etc/caddy \
9
  && npm install -g @deepseek-ai/dsh@latest \
10
- && apt-get update \
11
- && apt-get install -y --no-install-recommends curl ca-certificates \
12
- && curl -fsSL https://caddyserver.com/api/download?os=linux\&arch=amd64\&idempotency=1 \
13
- -o /usr/local/bin/caddy \
14
- && chmod +x /usr/local/bin/caddy \
15
- && apt-get clean \
16
- && rm -rf /var/lib/apt/lists/*
17
 
18
- WORKDIR /data/research
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- RUN cat > /etc/caddy/Caddyfile <<'EOF'
21
- :7860 {
22
- reverse_proxy 127.0.0.1:7861
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  EOF
25
 
 
 
 
 
 
26
  EXPOSE 7860
27
 
28
- CMD ["sh", "-c", "dsh web --no-open --port 7861 & exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"]
 
 
 
2
 
3
  ENV NODE_ENV=production \
4
  HOME=/root \
5
+ DSH_WORKSPACE=/data/research
 
6
 
7
+ RUN mkdir -p /data/research /app \
8
  && npm install -g @deepseek-ai/dsh@latest \
9
+ && cd /app \
10
+ && npm init -y \
11
+ && npm install http-proxy
 
 
 
 
12
 
13
+ WORKDIR /app
14
+
15
+ RUN cat > /app/proxy.js <<'EOF'
16
+ const http = require('http');
17
+ const httpProxy = require('http-proxy');
18
+
19
+ const proxy = httpProxy.createProxyServer({
20
+ target: 'http://127.0.0.1:7861',
21
+ changeOrigin: true,
22
+ ws: true,
23
+ xfwd: false,
24
+ secure: false
25
+ });
26
+
27
+ proxy.on('proxyReq', (proxyReq) => {
28
+ proxyReq.setHeader('Host', '127.0.0.1:7861');
29
+ proxyReq.setHeader('Origin', 'http://127.0.0.1:7861');
30
+ proxyReq.removeHeader('Referer');
31
+ });
32
+
33
+ proxy.on('error', (err, req, res) => {
34
+ console.error('Proxy error:', err.message);
35
+
36
+ if (res && !res.headersSent) {
37
+ res.writeHead(502, { 'Content-Type': 'text/plain' });
38
+ }
39
+
40
+ if (res && !res.writableEnded) {
41
+ res.end('DSH backend unavailable');
42
+ }
43
+ });
44
+
45
+ const server = http.createServer((req, res) => {
46
+ proxy.web(req, res);
47
+ });
48
+
49
+ server.on('upgrade', (req, socket, head) => {
50
+ proxy.ws(req, socket, head);
51
+ });
52
+
53
+ server.listen(7860, '0.0.0.0', () => {
54
+ console.log('Public proxy listening on 0.0.0.0:7860');
55
+ });
56
+ EOF
57
 
58
+ RUN cat > /app/start.sh <<'EOF'
59
+ #!/bin/sh
60
+ set -e
61
+
62
+ mkdir -p /data/research
63
+
64
+ echo "Starting DeepSeek Harness..."
65
+ dsh web --no-open --port 7861 &
66
+
67
+ DSH_PID=$!
68
+
69
+ echo "Waiting for DSH..."
70
+ for i in $(seq 1 60); do
71
+ if curl -fsS "http://127.0.0.1:7861/" >/dev/null 2>&1; then
72
+ break
73
+ fi
74
+ sleep 1
75
+ done
76
+
77
+ echo "Starting public proxy..."
78
+ node /app/proxy.js &
79
+
80
+ PROXY_PID=$!
81
+
82
+ trap 'kill $DSH_PID $PROXY_PID 2>/dev/null || true' TERM INT EXIT
83
+
84
+ wait $DSH_PID
85
  EOF
86
 
87
+ RUN chmod +x /app/start.sh \
88
+ && apt-get update \
89
+ && apt-get install -y --no-install-recommends curl \
90
+ && rm -rf /var/lib/apt/lists/*
91
+
92
  EXPOSE 7860
93
 
94
+ WORKDIR /data/research
95
+
96
+ CMD ["/app/start.sh"]