legends810 commited on
Commit
822eb5f
Β·
verified Β·
1 Parent(s): 8f42094

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -47
Dockerfile CHANGED
@@ -1,66 +1,32 @@
1
- ###############################################################################
2
- # n8n on Hugging-Face πŸ”Ή gzip compression HARD-OFF
3
- ###############################################################################
4
  FROM docker.n8n.io/n8nio/n8n:latest
5
 
6
- # ────────────────────── base env vars ──────────────────────
7
  ENV N8N_HOST=0.0.0.0 \
8
  N8N_PROTOCOL=http \
9
  DB_TYPE=sqlite \
10
- DB_SQLITE_DATABASE=/home/node/.n8n/database.sqlite \
11
  N8N_DISABLE_PRODUCTION_MAIN_PROCESS_RESPONSE_COMPRESSION=true \
12
  N8N_DISABLE_PRODUCTION_WEBHOOK_RESPONSE_COMPRESSION=true \
13
- N8N_BASIC_AUTH_ACTIVE=false \
14
- N8N_USER_MANAGEMENT_DISABLED=true \
15
- N8N_LOG_LEVEL=debug \
16
- N8N_CUSTOM_EXTENSIONS=/home/node/n8n-custom
17
 
18
- # ────────────────────── 1. custom extension ──────────────────────
19
  USER node
20
- RUN mkdir -p /home/node/n8n-custom/disable-gzip
 
 
 
 
21
 
22
- # package.json (loader ΰ€•ΰ₯‹ package ΰ€¦ΰ€Ώΰ€–ΰ€Ύΰ€¨ΰ€Ύ ΰ€œΰ€Όΰ€°ΰ₯‚ΰ€°ΰ₯€ ΰ€Ήΰ₯ˆ)
23
- RUN printf '{\n "name": "disable-gzip","version": "1.0.0","main": "index.js"\n}\n' \
24
- > /home/node/n8n-custom/disable-gzip/package.json
25
 
26
- # index.js β†’ compression layer ΰ€Ήΰ€Ÿΰ€Ύΰ€¨ΰ€Ύ + header strip
27
- RUN cat >/home/node/n8n-custom/disable-gzip/index.js <<'JS'
28
- module.exports = {
29
- init(app) {
30
- // compression middleware remove
31
- if (app?._router?.stack) {
32
- const before = app._router.stack.length;
33
- app._router.stack = app._router.stack.filter(
34
- (layer) => !(layer.handle && layer.handle.name === 'compression')
35
- );
36
- console.log(`πŸ—œοΈ Removed compression middleware β€’ stack ${before}β†’${app._router.stack.length}`);
37
- }
38
-
39
- // always unset Content-Encoding + stop proxy transform
40
- app.use((_req, res, next) => {
41
- res.removeHeader('Content-Encoding');
42
- res.setHeader('Cache-Control', 'no-transform');
43
- next();
44
- });
45
-
46
- console.log('βœ… Custom extension loaded β†’ gzip disabled globally');
47
- },
48
- };
49
- JS
50
-
51
- # ────────────────────── 2. start-script ──────────────────────
52
  USER root
53
  RUN cat >/usr/local/bin/start.sh <<'SH' && chmod +x /usr/local/bin/start.sh
54
  #!/usr/bin/env sh
55
  set -eu
 
56
 
57
- N8N_PORT="${PORT:-7860}"
58
- export N8N_PORT
59
-
60
- # build HF public URL (user/repo -> user-repo.hf.space)
61
  if [ -n "${SPACE_ID:-}" ]; then
62
- SPACE_SLUG=$(printf '%s' "$SPACE_ID" | tr '/_' '-')
63
- APP_URL="https://${SPACE_SLUG}.hf.space"
64
  else
65
  APP_URL="http://localhost:${N8N_PORT}"
66
  fi
@@ -69,7 +35,8 @@ export N8N_BASE_URL="$APP_URL"
69
  export WEBHOOK_URL="$APP_URL"
70
  export N8N_EDITOR_BASE_URL="$APP_URL"
71
 
72
- echo "πŸš€ n8n on $N8N_PORT β€’ Public: $APP_URL"
 
73
  exec n8n start
74
  SH
75
 
 
 
 
 
1
  FROM docker.n8n.io/n8nio/n8n:latest
2
 
 
3
  ENV N8N_HOST=0.0.0.0 \
4
  N8N_PROTOCOL=http \
5
  DB_TYPE=sqlite \
 
6
  N8N_DISABLE_PRODUCTION_MAIN_PROCESS_RESPONSE_COMPRESSION=true \
7
  N8N_DISABLE_PRODUCTION_WEBHOOK_RESPONSE_COMPRESSION=true \
8
+ N8N_LOG_LEVEL=debug
 
 
 
9
 
10
+ ################## 1. create preload script ##################
11
  USER node
12
+ RUN echo "/* kill gzip globally */\
13
+ const Module=require('module');\
14
+ Module._cache[require.resolve('compression')]={exports:()=>(_req,_res,next)=>next()};\
15
+ process.env.DISABLE_COMPRESSION_PATCH='loaded';" \
16
+ > /home/node/disable-gzip-preload.js
17
 
18
+ ################## 2. tell node to preload it ################
19
+ ENV NODE_OPTIONS="--require=/home/node/disable-gzip-preload.js"
 
20
 
21
+ ################## 3. start script for HF public URL #########
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  USER root
23
  RUN cat >/usr/local/bin/start.sh <<'SH' && chmod +x /usr/local/bin/start.sh
24
  #!/usr/bin/env sh
25
  set -eu
26
+ export N8N_PORT="${PORT:-7860}"
27
 
 
 
 
 
28
  if [ -n "${SPACE_ID:-}" ]; then
29
+ APP_URL="https://$(echo "$SPACE_ID" | tr '/_' '-').hf.space"
 
30
  else
31
  APP_URL="http://localhost:${N8N_PORT}"
32
  fi
 
35
  export WEBHOOK_URL="$APP_URL"
36
  export N8N_EDITOR_BASE_URL="$APP_URL"
37
 
38
+ echo "πŸš€ n8n starting β€’ public $APP_URL"
39
+ echo "πŸ—œοΈ gzip disabled via NODE_OPTIONS preload"
40
  exec n8n start
41
  SH
42