Spaces:
Sleeping
Sleeping
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +42 -22
Dockerfile
CHANGED
|
@@ -1,11 +1,32 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
# Install
|
| 5 |
RUN apk add --no-cache \
|
| 6 |
python3 \
|
| 7 |
make \
|
| 8 |
-
g++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
su-exec \
|
| 10 |
tini \
|
| 11 |
bash \
|
|
@@ -15,32 +36,31 @@ RUN apk add --no-cache \
|
|
| 15 |
ca-certificates \
|
| 16 |
tzdata
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
ENV N8N_PORT=7860 \
|
| 23 |
-
N8N_PROTOCOL=https \
|
| 24 |
-
N8N_USER_FOLDER=/data/.n8n \
|
| 25 |
-
NODE_ENV=production
|
| 26 |
-
|
| 27 |
-
# Setup permissions for the persistent bucket
|
| 28 |
-
USER root
|
| 29 |
-
RUN mkdir -p /data/.n8n && chown -R 1000:1000 /data/.n8n
|
| 30 |
-
|
| 31 |
-
# Create the n8n user (uid 1000)
|
| 32 |
RUN addgroup -g 1000 n8n && \
|
| 33 |
adduser -u 1000 -G n8n -s /bin/bash -D n8n
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
# Expose HF port
|
| 38 |
EXPOSE 7860
|
| 39 |
|
| 40 |
-
#
|
| 41 |
-
COPY
|
| 42 |
RUN chmod +x /start.sh
|
| 43 |
|
| 44 |
-
# Use tini as PID 1 to
|
| 45 |
ENTRYPOINT ["/sbin/tini", "--"]
|
| 46 |
CMD ["/start.sh"]
|
|
|
|
| 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
|
| 22 |
+
RUN npm install -g n8n@latest && \
|
| 23 |
+
npm cache clean --force
|
| 24 |
+
|
| 25 |
+
# --------------- Stage 2: Runtime (lean, no build toolchain) ------------------
|
| 26 |
+
FROM node:22-alpine
|
| 27 |
+
|
| 28 |
+
# Runtime-only dependencies
|
| 29 |
+
RUN apk add --no-cache \
|
| 30 |
su-exec \
|
| 31 |
tini \
|
| 32 |
bash \
|
|
|
|
| 36 |
ca-certificates \
|
| 37 |
tzdata
|
| 38 |
|
| 39 |
+
# Copy the globally-installed n8n from the build stage
|
| 40 |
+
COPY --from=build /usr/local/lib/node_modules /usr/local/lib/node_modules
|
| 41 |
+
COPY --from=build /usr/local/bin/n8n /usr/local/bin/n8n
|
| 42 |
|
| 43 |
+
# Create the non-root user that n8n will run as (uid/gid 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
RUN addgroup -g 1000 n8n && \
|
| 45 |
adduser -u 1000 -G n8n -s /bin/bash -D n8n
|
| 46 |
|
| 47 |
+
# ---------- Environment -------------------------------------------------------
|
| 48 |
+
ENV N8N_PORT=7860 \
|
| 49 |
+
N8N_PROTOCOL=https \
|
| 50 |
+
N8N_USER_FOLDER=/data/.n8n \
|
| 51 |
+
N8N_DIAGNOSTICS_ENABLED=false \
|
| 52 |
+
N8N_HIRING_BANNER_ENABLED=false \
|
| 53 |
+
N8N_PERSONALIZATION_ENABLED=false \
|
| 54 |
+
NODE_ENV=production \
|
| 55 |
+
GENERIC_TIMEZONE=UTC
|
| 56 |
|
| 57 |
+
# Expose the HF-required port
|
| 58 |
EXPOSE 7860
|
| 59 |
|
| 60 |
+
# ---------- Entrypoint --------------------------------------------------------
|
| 61 |
+
COPY start.sh /start.sh
|
| 62 |
RUN chmod +x /start.sh
|
| 63 |
|
| 64 |
+
# Use tini as PID 1 to reap zombies and forward signals
|
| 65 |
ENTRYPOINT ["/sbin/tini", "--"]
|
| 66 |
CMD ["/start.sh"]
|