legends810 commited on
Commit
bef4e0a
Β·
verified Β·
1 Parent(s): 940abbb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -13
Dockerfile CHANGED
@@ -1,11 +1,11 @@
1
- # Use official n8n Docker image
2
- FROM n8nio/n8n:latest
3
 
4
- # Switch to root for setup
5
  USER root
6
 
7
- # Install curl for health checks
8
- RUN apk add --no-cache curl
9
 
10
  # Hugging Face Spaces specific settings
11
  ENV N8N_PORT=7860
@@ -37,9 +37,21 @@ ENV N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false
37
  # Performance settings
38
  ENV N8N_LOG_LEVEL=info
39
 
40
- # Create startup script
41
- RUN echo '#!/bin/sh' > /start.sh && \
 
 
 
 
 
 
 
 
 
 
42
  echo 'echo "πŸš€ ===== n8n Starting on Hugging Face Spaces ====="' >> /start.sh && \
 
 
43
  echo 'if [ -n "$SPACE_ID" ]; then' >> /start.sh && \
44
  echo ' APP_URL="https://$SPACE_ID.hf.space"' >> /start.sh && \
45
  echo 'elif [ -n "$SPACE_HOST" ]; then' >> /start.sh && \
@@ -47,19 +59,31 @@ RUN echo '#!/bin/sh' > /start.sh && \
47
  echo 'else' >> /start.sh && \
48
  echo ' APP_URL="http://localhost:7860"' >> /start.sh && \
49
  echo 'fi' >> /start.sh && \
 
 
 
 
50
  echo 'export N8N_EDITOR_BASE_URL="$APP_URL"' >> /start.sh && \
51
- echo 'export WEBHOOK_URL="$APP_URL"' >> /start.sh && \
52
  echo 'echo "🌐 n8n will be available at: $APP_URL"' >> /start.sh && \
53
- echo 'echo "πŸ“Š Configuration: Port $N8N_PORT | SQLite | No Auth | Compression OFF"' >> /start.sh && \
 
 
 
 
 
 
 
54
  echo 'echo "🎯 Starting n8n server..."' >> /start.sh && \
55
- echo 'cd /home/node' >> /start.sh && \
56
- echo 'exec tini -- n8n start' >> /start.sh
 
57
 
58
  # Make script executable
59
  RUN chmod +x /start.sh
60
 
61
- # Switch back to node user
62
- USER node
63
 
64
  # Expose port for Hugging Face Spaces
65
  EXPOSE 7860
 
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
 
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 && \
 
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