legends810 commited on
Commit
0f57f8d
Β·
verified Β·
1 Parent(s): bef4e0a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +48 -62
Dockerfile CHANGED
@@ -1,96 +1,82 @@
1
- # Use official n8n Docker image instead of building from scratch
2
  FROM docker.n8n.io/n8nio/n8n:latest
3
 
4
  # Switch to root for configuration
5
  USER root
6
 
7
- # Install additional tools for Hugging Face Spaces
8
  RUN apk add --no-cache curl bash
9
 
10
- # Hugging Face Spaces specific settings
11
  ENV N8N_PORT=7860
12
  ENV N8N_HOST=0.0.0.0
13
  ENV N8N_PROTOCOL=https
 
14
 
15
- # Database configuration - Using SQLite for HF Spaces compatibility
16
  ENV DB_TYPE=sqlite
17
  ENV DB_SQLITE_DATABASE=/home/node/.n8n/database.sqlite
18
 
19
- # Community packages enable ΰ€•ΰ€°ΰ₯‡ΰ€‚
20
- ENV N8N_COMMUNITY_PACKAGES_ENABLED=true
21
- ENV N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
22
-
23
- # MOST IMPORTANT: gzip compression disable ΰ€•ΰ€°ΰ₯‡ΰ€‚ (ΰ€†ΰ€ͺΰ€•ΰ₯€ main problem ΰ€•ΰ€Ύ solution)
24
- ENV COMPRESSION_ENABLED=false
25
- ENV N8N_DISABLE_GZIP=true
26
- ENV N8N_DISABLE_PRODUCTION_MAIN_PROCESS_RESPONSE_COMPRESSION=true
27
- ENV DISABLE_COMPRESSION=true
28
- ENV NODE_OPTIONS="--max-old-space-size=4096"
29
-
30
- # NO AUTHENTICATION
31
  ENV N8N_BASIC_AUTH_ACTIVE=false
32
  ENV N8N_USER_MANAGEMENT_DISABLED=true
33
 
34
- # File permissions ΰ€”ΰ€° encryption key settings
35
- ENV N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
36
 
37
- # Performance settings
38
- ENV N8N_LOG_LEVEL=info
39
 
40
- # Switch to node user and create directories
41
- USER node
 
42
 
43
- # Create user directories with proper permissions
44
- RUN mkdir -p /home/node/.n8n/database /home/node/.n8n/config /home/node/.n8n/workflows /home/node/.n8n/logs
 
45
 
46
- # Switch back to root for script creation
47
- USER root
48
 
49
- # Create startup script with URL display
50
- RUN echo '#!/bin/bash' > /start.sh && \
51
- echo '' >> /start.sh && \
52
- echo 'echo "πŸš€ ===== n8n Starting on Hugging Face Spaces ====="' >> /start.sh && \
53
- echo '' >> /start.sh && \
54
- echo '# Dynamic URL detection' >> /start.sh && \
55
- echo 'if [ -n "$SPACE_ID" ]; then' >> /start.sh && \
56
- echo ' APP_URL="https://$SPACE_ID.hf.space"' >> /start.sh && \
57
- echo 'elif [ -n "$SPACE_HOST" ]; then' >> /start.sh && \
58
- echo ' APP_URL="https://$SPACE_HOST"' >> /start.sh && \
59
- echo 'else' >> /start.sh && \
60
- echo ' APP_URL="http://localhost:7860"' >> /start.sh && \
61
- echo 'fi' >> /start.sh && \
62
- echo '' >> /start.sh && \
63
- echo '# Set dynamic URLs' >> /start.sh && \
64
- echo 'export N8N_BASE_URL="$APP_URL/"' >> /start.sh && \
65
- echo 'export WEBHOOK_URL="$APP_URL/"' >> /start.sh && \
66
- echo 'export N8N_EDITOR_BASE_URL="$APP_URL"' >> /start.sh && \
67
- echo '' >> /start.sh && \
68
- echo 'echo "🌐 n8n will be available at: $APP_URL"' >> /start.sh && \
69
- echo 'echo "πŸ“Š Configuration:"' >> /start.sh && \
70
- echo 'echo " - Port: $N8N_PORT"' >> /start.sh && \
71
- echo 'echo " - Database: SQLite (local)"' >> /start.sh && \
72
- echo 'echo " - Compression: DISABLED βœ…"' >> /start.sh && \
73
- echo 'echo " - Community Packages: ENABLED βœ…"' >> /start.sh && \
74
- echo 'echo " - Authentication: DISABLED βœ…"' >> /start.sh && \
75
- echo 'echo ""' >> /start.sh && \
76
- echo '' >> /start.sh && \
77
- echo 'echo "🎯 Starting n8n server..."' >> /start.sh && \
78
- echo '' >> /start.sh && \
79
- echo '# Start n8n with proper user' >> /start.sh && \
80
- echo 'su node -c "n8n start"' >> /start.sh
81
 
82
  # Make script executable
83
  RUN chmod +x /start.sh
84
 
 
 
 
 
 
 
85
  # Set working directory
86
  WORKDIR /home/node
87
 
88
- # Expose port for Hugging Face Spaces
89
  EXPOSE 7860
90
 
91
  # Health check
92
- HEALTHCHECK --interval=30s --timeout=10s --start-period=45s --retries=3 \
93
- CMD curl -f http://localhost:7860/healthz || curl -f http://localhost:7860/ || exit 1
94
 
95
- # Use custom startup script
96
  CMD ["/start.sh"]
 
1
+ # Use official n8n Docker image
2
  FROM docker.n8n.io/n8nio/n8n:latest
3
 
4
  # Switch to root for configuration
5
  USER root
6
 
7
+ # Install additional tools
8
  RUN apk add --no-cache curl bash
9
 
10
+ # Set n8n specific environment variables
11
  ENV N8N_PORT=7860
12
  ENV N8N_HOST=0.0.0.0
13
  ENV N8N_PROTOCOL=https
14
+ ENV N8N_LOG_LEVEL=info
15
 
16
+ # Database configuration - Using SQLite for HF Spaces
17
  ENV DB_TYPE=sqlite
18
  ENV DB_SQLITE_DATABASE=/home/node/.n8n/database.sqlite
19
 
20
+ # Disable authentication completely
 
 
 
 
 
 
 
 
 
 
 
21
  ENV N8N_BASIC_AUTH_ACTIVE=false
22
  ENV N8N_USER_MANAGEMENT_DISABLED=true
23
 
24
+ # Enable execution mode
25
+ ENV EXECUTIONS_MODE=regular
26
 
27
+ # Set webhook URL dynamically
28
+ ENV WEBHOOK_URL=\$WEBHOOK_URL
29
 
30
+ # Create necessary directories with correct permissions
31
+ RUN mkdir -p /home/node/.n8n && \
32
+ chown -R node:node /home/node/.n8n
33
 
34
+ # Create startup script
35
+ RUN cat > /start.sh << 'EOF'
36
+ #!/bin/bash
37
 
38
+ echo "πŸš€ Starting n8n on Hugging Face Spaces..."
 
39
 
40
+ # Detect Hugging Face Space URL
41
+ if [ -n "$SPACE_ID" ]; then
42
+ export WEBHOOK_URL="https://${SPACE_ID}.hf.space/"
43
+ export N8N_EDITOR_BASE_URL="https://${SPACE_ID}.hf.space"
44
+ elif [ -n "$SPACE_HOST" ]; then
45
+ export WEBHOOK_URL="https://${SPACE_HOST}/"
46
+ export N8N_EDITOR_BASE_URL="https://${SPACE_HOST}"
47
+ else
48
+ export WEBHOOK_URL="http://localhost:7860/"
49
+ export N8N_EDITOR_BASE_URL="http://localhost:7860"
50
+ fi
51
+
52
+ echo "πŸ“Œ n8n URL: $WEBHOOK_URL"
53
+ echo "πŸ”§ Configuration:"
54
+ echo " - Port: 7860"
55
+ echo " - Database: SQLite"
56
+ echo " - Authentication: Disabled"
57
+
58
+ # Start n8n
59
+ exec n8n
60
+ EOF
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  # Make script executable
63
  RUN chmod +x /start.sh
64
 
65
+ # Switch to node user
66
+ USER node
67
+
68
+ # Create n8n directories
69
+ RUN mkdir -p /home/node/.n8n
70
+
71
  # Set working directory
72
  WORKDIR /home/node
73
 
74
+ # Expose port
75
  EXPOSE 7860
76
 
77
  # Health check
78
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
79
+ CMD curl -f http://localhost:7860/healthz || exit 1
80
 
81
+ # Start n8n
82
  CMD ["/start.sh"]