GTO-Custom-AI commited on
Commit
f34bdbb
Β·
verified Β·
1 Parent(s): 235e0d9

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -51
Dockerfile CHANGED
@@ -1,29 +1,4 @@
1
- # ==============================================================================
2
- # Dockerfile – n8n on Hugging Face Spaces
3
- #
4
- # Solves:
5
- # 1. "Command not found" β†’ uses node:22-alpine base (has /bin/sh + bash)
6
- # 2. "Permissions too wide" β†’ start.sh fixes perms before dropping to uid 1000
7
- # 3. Port 7860 β†’ HF Spaces requirement
8
- # 4. Persistence β†’ /data/.n8n backed by HF persistent storage
9
- # 5. Node >= 22.16 β†’ required by n8n >= 2.15 and isolated-vm >= 6.1
10
- # ==============================================================================
11
-
12
- # --------------- Stage 1: Build (includes native compilation toolchain) -------
13
- FROM node:22-alpine AS build
14
-
15
- # Install native build dependencies for isolated-vm and other C++ addons
16
- RUN apk add --no-cache \
17
- python3 \
18
- make \
19
- g++
20
-
21
- # Install n8n globally (semver installed explicitly to avoid module resolution
22
- # issues when running via su-exec in the runtime stage)
23
- RUN npm install -g semver n8n@latest --omit=dev && \
24
- npm cache clean --force
25
-
26
- # --------------- Stage 2: Runtime (lean, no build toolchain) ------------------
27
  FROM node:22-alpine
28
 
29
  # Runtime-only dependencies
@@ -35,37 +10,36 @@ RUN apk add --no-cache \
35
  git \
36
  openssh-client \
37
  ca-certificates \
38
- tzdata
 
 
 
 
 
 
 
 
39
 
40
- # Copy the globally-installed n8n from the build stage
41
- COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules
 
 
 
42
 
43
- # Re-link the n8n binary from source (the copied symlink may be broken)
44
- RUN ln -sf /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n
 
45
 
46
- # Note: node:22-alpine already provides user "node" at uid/gid 1000.
47
- # No addgroup/adduser needed β€” start.sh uses su-exec 1000:1000.
 
48
 
49
- # ---------- Environment -------------------------------------------------------
50
- # NODE_PATH tells Node where to find globally-installed modules (fixes
51
- # "Cannot find module 'semver/functions/satisfies'" at runtime)
52
- ENV NODE_PATH=/usr/local/lib/node_modules \
53
- N8N_PORT=7860 \
54
- N8N_PROTOCOL=https \
55
- N8N_USER_FOLDER=/data/.n8n \
56
- N8N_DIAGNOSTICS_ENABLED=false \
57
- N8N_HIRING_BANNER_ENABLED=false \
58
- N8N_PERSONALIZATION_ENABLED=false \
59
- NODE_ENV=production \
60
- GENERIC_TIMEZONE=UTC
61
 
62
- # Expose the HF-required port
63
- EXPOSE 7860
64
 
65
- # ---------- Entrypoint --------------------------------------------------------
66
- COPY start.sh /start.sh
67
- RUN chmod +x /start.sh
68
 
69
- # Use tini as PID 1 to reap zombies and forward signals
70
  ENTRYPOINT ["/sbin/tini", "--"]
71
  CMD ["/start.sh"]
 
1
+ # Use the official n8n image as the base
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  FROM node:22-alpine
3
 
4
  # Runtime-only dependencies
 
10
  git \
11
  openssh-client \
12
  ca-certificates \
13
+ tzdata \
14
+ sqlite
15
+
16
+ # Copy globally-installed n8n from build (assuming we use the build stage from before or just a fresh install)
17
+ # To ensure consistency, I'll just do a clean install in this final version to be safe
18
+ RUN apk add --no-cache python3 make g++ && \
19
+ npm install -g n8n@latest && \
20
+ apk del python3 make g++ && \
21
+ npm cache clean --force
22
 
23
+ # HF Spaces requirements
24
+ ENV N8N_PORT=7860 \
25
+ N8N_PROTOCOL=https \
26
+ N8N_USER_FOLDER=/data/.n8n \
27
+ NODE_ENV=production
28
 
29
+ # Setup permissions
30
+ USER root
31
+ RUN mkdir -p /data/.n8n && chown -R 1000:1000 /data/.n8n
32
 
33
+ # Copy the surgical activation script
34
+ COPY activate_n8n.sh /activate_n8n.sh
35
+ RUN chmod +x /activate_n8n.sh
36
 
37
+ # Updated start.sh to call the activator first
38
+ RUN echo '#!/bin/sh\n/activate_n8n.sh\nexec su-exec node n8n start' > /start.sh && chmod +x /start.sh
 
 
 
 
 
 
 
 
 
 
39
 
40
+ USER node
 
41
 
42
+ EXPOSE 7860
 
 
43
 
 
44
  ENTRYPOINT ["/sbin/tini", "--"]
45
  CMD ["/start.sh"]