FROM node:20-alpine # Set user to root for installation USER root # Arguments that can be passed at build time ARG N8N_PATH=/usr/local/lib/node_modules/n8n ARG BASE_PATH=/root/.n8n ARG DATABASE_PATH=$BASE_PATH/database ARG CONFIG_PATH=$BASE_PATH/config ARG WORKFLOWS_PATH=$BASE_PATH/workflows ARG LOGS_PATH=$BASE_PATH/logs # Install system dependencies RUN apk add --no-cache \ git \ python3 \ py3-pip \ make \ g++ \ build-base \ cairo-dev \ pango-dev \ chromium \ postgresql-client \ ffmpeg \ yt-dlp \ tini # Set environment variables for Puppeteer ENV PUPPETEER_SKIP_DOWNLOAD=true ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser # Set n8n environment variables for Hugging Face Spaces ENV N8N_HOST=0.0.0.0 ENV N8N_PORT=7860 ENV N8N_PROTOCOL=https ENV N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true # Install n8n globally (using LTS version for stability) RUN npm install -g n8n@latest # Create necessary directories RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH \ && chmod -R 777 $BASE_PATH # Set working directory WORKDIR /data # Expose port for Hugging Face Spaces EXPOSE 7860 # Use tini as init system and start n8n ENTRYPOINT ["tini", "--"] CMD ["n8n", "start"]