kylsprt commited on
Commit
abdabf9
·
verified ·
1 Parent(s): ccf737b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -19
Dockerfile CHANGED
@@ -3,7 +3,7 @@ FROM node:18-alpine
3
  RUN apk add --no-cache git python3 make g++
4
 
5
  RUN git clone https://github.com/CorentinTh/it-tools.git /app && \
6
- cd /app && npm install && npm run build && \
7
  npm install -g serve && \
8
  rm -rf /root/.npm /tmp/*
9
 
@@ -11,23 +11,13 @@ RUN mkdir -p /gw && cd /gw && npm install http-proxy
11
 
12
  RUN cat > /gw/gateway.js << 'GWEOF'
13
  var http = require('http');
14
- var httpProxy = require('http-proxy');
15
  var DOMAIN = process.env.DOMAIN || '';
16
  var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:3001', ws: true });
17
- proxy.on('error', function(e, req, res) {
18
- if (res && res.writeHead) { res.writeHead(502); res.end('502'); }
19
- });
20
- function ok(req) {
21
- if (!DOMAIN) return true;
22
- var h = (req.headers['x-real-domain'] || '') + '|' + (req.headers['x-forwarded-host'] || '') + '|' + (req.headers['host'] || '');
23
- return h.indexOf(DOMAIN) !== -1;
24
- }
25
- var s = http.createServer(function(req, res) {
26
- if (ok(req)) { proxy.web(req, res); } else { res.writeHead(200, {'Content-Type':'text/plain'}); res.end('200 OK'); }
27
- });
28
- s.on('upgrade', function(req, socket, head) {
29
- if (ok(req)) { proxy.ws(req, socket, head); } else { socket.destroy(); }
30
- });
31
  s.listen(7860, function() { console.log('[GW] 7860'); });
32
  GWEOF
33
 
@@ -39,9 +29,8 @@ cd /gw && exec node gateway.js
39
  SHEOF
40
 
41
  RUN chmod +x /gw/start.sh
 
42
 
43
- RUN adduser -D -u 1000 user && chown -R user:user /gw
44
-
45
- USER user
46
  EXPOSE 7860
47
  CMD ["/gw/start.sh"]
 
3
  RUN apk add --no-cache git python3 make g++
4
 
5
  RUN git clone https://github.com/CorentinTh/it-tools.git /app && \
6
+ cd /app && npm install --legacy-peer-deps && npm run build && \
7
  npm install -g serve && \
8
  rm -rf /root/.npm /tmp/*
9
 
 
11
 
12
  RUN cat > /gw/gateway.js << 'GWEOF'
13
  var http = require('http');
14
+ var httpProxy = require('/gw/node_modules/http-proxy');
15
  var DOMAIN = process.env.DOMAIN || '';
16
  var proxy = httpProxy.createProxyServer({ target: 'http://127.0.0.1:3001', ws: true });
17
+ proxy.on('error', function(e, req, res) { if (res && res.writeHead) { res.writeHead(502); res.end('502'); } });
18
+ 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; }
19
+ 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'); } });
20
+ s.on('upgrade', function(req, socket, head) { if (ok(req)) { proxy.ws(req, socket, head); } else { socket.destroy(); } });
 
 
 
 
 
 
 
 
 
 
21
  s.listen(7860, function() { console.log('[GW] 7860'); });
22
  GWEOF
23
 
 
29
  SHEOF
30
 
31
  RUN chmod +x /gw/start.sh
32
+ RUN chown -R node:node /gw
33
 
34
+ USER node
 
 
35
  EXPOSE 7860
36
  CMD ["/gw/start.sh"]