Spaces:
Sleeping
Sleeping
Upload Dockerfile with huggingface_hub
Browse files- Dockerfile +71 -16
Dockerfile
CHANGED
|
@@ -1,24 +1,79 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
|
|
|
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
RUN
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
|
|
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
EXPOSE 7860
|
| 22 |
|
| 23 |
-
#
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==============================================================================
|
| 2 |
+
# Dockerfile – n8n on Hugging Face Spaces
|
| 3 |
+
#
|
| 4 |
+
# Solves:
|
| 5 |
+
# 1. "Command not found" → uses alpine base with a real shell
|
| 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 |
+
# ==============================================================================
|
| 10 |
|
| 11 |
+
# --------------- Stage 1: Build on Alpine with shell --------------------------
|
| 12 |
+
FROM alpine:3.19 AS base
|
| 13 |
|
| 14 |
+
# Install Node.js LTS, npm, and runtime dependencies n8n needs
|
| 15 |
+
RUN apk add --no-cache \
|
| 16 |
+
nodejs=~20 \
|
| 17 |
+
npm \
|
| 18 |
+
su-exec \
|
| 19 |
+
tini \
|
| 20 |
+
bash \
|
| 21 |
+
curl \
|
| 22 |
+
git \
|
| 23 |
+
openssh-client \
|
| 24 |
+
ca-certificates \
|
| 25 |
+
tzdata \
|
| 26 |
+
python3 \
|
| 27 |
+
make \
|
| 28 |
+
g++
|
| 29 |
|
| 30 |
+
# Install n8n globally
|
| 31 |
+
RUN npm install -g n8n@latest && \
|
| 32 |
+
npm cache clean --force
|
| 33 |
+
|
| 34 |
+
# --------------- Stage 2: Runtime image --------------------------------------
|
| 35 |
+
FROM alpine:3.19
|
| 36 |
+
|
| 37 |
+
# Re-install only runtime dependencies (no build toolchain)
|
| 38 |
+
RUN apk add --no-cache \
|
| 39 |
+
nodejs=~20 \
|
| 40 |
+
npm \
|
| 41 |
+
su-exec \
|
| 42 |
+
tini \
|
| 43 |
+
bash \
|
| 44 |
+
curl \
|
| 45 |
+
git \
|
| 46 |
+
openssh-client \
|
| 47 |
+
ca-certificates \
|
| 48 |
+
tzdata
|
| 49 |
|
| 50 |
+
# Copy the globally-installed n8n from the build stage
|
| 51 |
+
COPY --from=base /usr/lib/node_modules /usr/lib/node_modules
|
| 52 |
+
COPY --from=base /usr/local/lib/node_modules /usr/local/lib/node_modules
|
| 53 |
+
# Symlink the n8n binary so it's on PATH
|
| 54 |
+
RUN ln -sf /usr/local/lib/node_modules/n8n/bin/n8n /usr/local/bin/n8n
|
| 55 |
|
| 56 |
+
# Create the non-root user that n8n will run as (uid/gid 1000)
|
| 57 |
+
RUN addgroup -g 1000 n8n && \
|
| 58 |
+
adduser -u 1000 -G n8n -s /bin/bash -D n8n
|
| 59 |
|
| 60 |
+
# ---------- Environment -------------------------------------------------------
|
| 61 |
+
ENV N8N_PORT=7860 \
|
| 62 |
+
N8N_PROTOCOL=https \
|
| 63 |
+
N8N_USER_FOLDER=/data/.n8n \
|
| 64 |
+
N8N_DIAGNOSTICS_ENABLED=false \
|
| 65 |
+
N8N_HIRING_BANNER_ENABLED=false \
|
| 66 |
+
N8N_PERSONALIZATION_ENABLED=false \
|
| 67 |
+
NODE_ENV=production \
|
| 68 |
+
GENERIC_TIMEZONE=UTC
|
| 69 |
+
|
| 70 |
+
# Expose the HF-required port
|
| 71 |
EXPOSE 7860
|
| 72 |
|
| 73 |
+
# ---------- Entrypoint --------------------------------------------------------
|
| 74 |
+
COPY start.sh /start.sh
|
| 75 |
+
RUN chmod +x /start.sh
|
| 76 |
+
|
| 77 |
+
# Use tini as PID 1 to reap zombies and forward signals
|
| 78 |
+
ENTRYPOINT ["/sbin/tini", "--"]
|
| 79 |
+
CMD ["/start.sh"]
|