Testing / Dockerfile
legends810's picture
Update Dockerfile
bd22336 verified
raw
history blame
2.21 kB
###############################################################################
# n8n for Hugging Face Spaces – single-file Docker recipe
###############################################################################
FROM docker.n8n.io/n8nio/n8n:latest
########## Runtime-level env vars #############################################
# HF reverse-proxy देगा $PORT; 7860 fallback local dev के लिए
ENV N8N_HOST=0.0.0.0 \
N8N_PROTOCOL=http \
DB_TYPE=sqlite \
DB_SQLITE_DATABASE=/home/node/.n8n/database.sqlite \
N8N_COMMUNITY_PACKAGES_ENABLED=true \
N8N_DISABLE_PRODUCTION_MAIN_PROCESS_RESPONSE_COMPRESSION=true \
N8N_BASIC_AUTH_ACTIVE=false \
N8N_USER_MANAGEMENT_DISABLED=true \
N8N_LOG_LEVEL=info
########## create tiny start script inside the image ##########################
USER root
RUN set -eux; \
cat >/usr/local/bin/start.sh <<'BASH' && \
chmod +x /usr/local/bin/start.sh
#!/usr/bin/env bash
set -euo pipefail
export N8N_PORT="${PORT:-7860}" # HF देता है $PORT, लोकली 7860
# --------- figure out public URL (for webhooks / editor) --------------------
if [ -n "${SPACE_ID:-}" ]; then
APP_URL="https://${SPACE_ID}.hf.space"
elif [ -n "${SPACE_HOST:-}" ]; then # older env-var
APP_URL="https://${SPACE_HOST}"
else
APP_URL="http://localhost:${N8N_PORT}"
fi
export N8N_BASE_URL="${APP_URL}/"
export WEBHOOK_URL="${APP_URL}/"
export N8N_EDITOR_BASE_URL="${APP_URL}"
echo "🚀 n8n is starting on port ${N8N_PORT}"
echo "🌐 Public URL : ${APP_URL}"
echo "📚 DB : SQLite"
echo "🔒 Authentication : disabled"
echo "📦 Community packages: enabled"
echo "🗜️ Compression : disabled"
echo
exec su-exec node n8n start
BASH
USER node
########## (optional) expose default port #####################################
EXPOSE 7860
########## healthcheck ########################################################
HEALTHCHECK --interval=30s --timeout=10s --start-period=45s --retries=3 \
CMD curl -f http://localhost:${PORT:-7860}/healthz || exit 1
########## container entrypoint ###############################################
ENTRYPOINT ["tini", "--"]
CMD ["start.sh"]