kylsprt commited on
Commit
5cdcd63
·
verified ·
1 Parent(s): 18ca829

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -19
Dockerfile CHANGED
@@ -9,23 +9,13 @@ RUN mkdir -p /gw && cd /gw && npm install http-proxy
9
 
10
  RUN cat > /gw/gateway.js << 'GWEOF'
11
  var http = require('http');
12
- var httpProxy = require('http-proxy');
13
  var DOMAIN = process.env.DOMAIN || '';
14
  var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:3001', ws: true });
15
- proxy.on('error', function(e, req, res) {
16
- if (res && res.writeHead) { res.writeHead(502); res.end('502'); }
17
- });
18
- function ok(req) {
19
- if (!DOMAIN) return true;
20
- var h = (req.headers['x-real-domain'] || '') + '|' + (req.headers['x-forwarded-host'] || '') + '|' + (req.headers['host'] || '');
21
- return h.indexOf(DOMAIN) !== -1;
22
- }
23
- var s = http.createServer(function(req, res) {
24
- if (ok(req)) { proxy.web(req, res); } else { res.writeHead(200, {'Content-Type':'text/plain'}); res.end('200 OK'); }
25
- });
26
- s.on('upgrade', function(req, socket, head) {
27
- if (ok(req)) { proxy.ws(req, socket, head); } else { socket.destroy(); }
28
- });
29
  s.listen(7860, function() { console.log('[GW] 7860'); });
30
  GWEOF
31
 
@@ -37,10 +27,8 @@ cd /gw && exec node gateway.js
37
  SHEOF
38
 
39
  RUN chmod +x /gw/start.sh
 
40
 
41
- RUN adduser -D -u 1000 user && \
42
- chown -R user:user /app /gw
43
-
44
- USER user
45
  EXPOSE 7860
46
  CMD ["/gw/start.sh"]
 
9
 
10
  RUN cat > /gw/gateway.js << 'GWEOF'
11
  var http = require('http');
12
+ var httpProxy = require('/gw/node_modules/http-proxy');
13
  var DOMAIN = process.env.DOMAIN || '';
14
  var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:3001', ws: true });
15
+ proxy.on('error', function(e, req, res) { if (res && res.writeHead) { res.writeHead(502); res.end('502'); } });
16
+ function ok(req) { if (!DOMAIN) return true; var h = (req.headers['x-real-domain']||'')+'|'+(req.headers['x-forwarded-host']||'')+'|'+(req.headers['host']||''); return h.indexOf(DOMAIN) !== -1; }
17
+ var s = http.createServer(function(req, res) { if (ok(req)) { proxy.web(req, res); } else { res.writeHead(200,{'Content-Type':'text/plain'}); res.end('200 OK'); } });
18
+ s.on('upgrade', function(req, socket, head) { if (ok(req)) { proxy.ws(req, socket, head); } else { socket.destroy(); } });
 
 
 
 
 
 
 
 
 
 
19
  s.listen(7860, function() { console.log('[GW] 7860'); });
20
  GWEOF
21
 
 
27
  SHEOF
28
 
29
  RUN chmod +x /gw/start.sh
30
+ RUN chown -R node:node /app /gw
31
 
32
+ USER node
 
 
 
33
  EXPOSE 7860
34
  CMD ["/gw/start.sh"]