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

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -74
Dockerfile CHANGED
@@ -1,45 +1,11 @@
1
- FROM node:18-alpine
 
2
 
3
- # Set user to root for installation
4
  USER root
5
 
6
- # Arguments that can be passed at build time
7
- ARG N8N_PATH=/usr/local/lib/node_modules/n8n
8
- ARG BASE_PATH=/root/.n8n
9
- ARG DATABASE_PATH=$BASE_PATH/database
10
- ARG CONFIG_PATH=$BASE_PATH/config
11
- ARG WORKFLOWS_PATH=$BASE_PATH/workflows
12
- ARG LOGS_PATH=$BASE_PATH/logs
13
-
14
- # Install system dependencies
15
- RUN apk add --no-cache \
16
- git \
17
- python3 \
18
- py3-pip \
19
- make \
20
- g++ \
21
- build-base \
22
- cairo-dev \
23
- pango-dev \
24
- chromium \
25
- postgresql-client \
26
- ffmpeg \
27
- yt-dlp \
28
- duplicity \
29
- curl \
30
- bash
31
-
32
- # Set environment variables for Chromium
33
- ENV PUPPETEER_SKIP_DOWNLOAD=true
34
- ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
35
-
36
- # Install n8n globally
37
- RUN npm install -g n8n@1.94.1
38
-
39
- # Create necessary directories with proper permissions
40
- RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH \
41
- && chmod -R 755 $BASE_PATH \
42
- && chown -R node:node $BASE_PATH
43
 
44
  # Hugging Face Spaces specific settings
45
  ENV N8N_PORT=7860
@@ -65,25 +31,15 @@ ENV NODE_OPTIONS="--max-old-space-size=4096"
65
  ENV N8N_BASIC_AUTH_ACTIVE=false
66
  ENV N8N_USER_MANAGEMENT_DISABLED=true
67
 
 
 
 
68
  # Performance settings
69
  ENV N8N_LOG_LEVEL=info
70
- ENV N8N_DISABLE_PRODUCTION_MAIN_PROCESS=false
71
 
72
- # Switch to node user before creating directories
73
- USER node
74
-
75
- # Create user directories with proper permissions
76
- RUN mkdir -p /home/node/.n8n/database /home/node/.n8n/config /home/node/.n8n/workflows /home/node/.n8n/logs
77
-
78
- # Switch back to root for script creation
79
- USER root
80
-
81
- # Create startup script with URL display
82
- RUN echo '#!/bin/bash' > /start.sh && \
83
- echo '' >> /start.sh && \
84
  echo 'echo "πŸš€ ===== n8n Starting on Hugging Face Spaces ====="' >> /start.sh && \
85
- echo '' >> /start.sh && \
86
- echo '# Dynamic URL detection' >> /start.sh && \
87
  echo 'if [ -n "$SPACE_ID" ]; then' >> /start.sh && \
88
  echo ' APP_URL="https://$SPACE_ID.hf.space"' >> /start.sh && \
89
  echo 'elif [ -n "$SPACE_HOST" ]; then' >> /start.sh && \
@@ -91,33 +47,19 @@ RUN echo '#!/bin/bash' > /start.sh && \
91
  echo 'else' >> /start.sh && \
92
  echo ' APP_URL="http://localhost:7860"' >> /start.sh && \
93
  echo 'fi' >> /start.sh && \
94
- echo '' >> /start.sh && \
95
- echo '# Set dynamic URLs' >> /start.sh && \
96
- echo 'export N8N_BASE_URL="$APP_URL/"' >> /start.sh && \
97
- echo 'export WEBHOOK_URL="$APP_URL/"' >> /start.sh && \
98
  echo 'export N8N_EDITOR_BASE_URL="$APP_URL"' >> /start.sh && \
99
- echo '' >> /start.sh && \
100
  echo 'echo "🌐 n8n will be available at: $APP_URL"' >> /start.sh && \
101
- echo 'echo "πŸ“Š Configuration:"' >> /start.sh && \
102
- echo 'echo " - Port: $N8N_PORT"' >> /start.sh && \
103
- echo 'echo " - Database: SQLite (in-memory)"' >> /start.sh && \
104
- echo 'echo " - Compression: DISABLED βœ…"' >> /start.sh && \
105
- echo 'echo " - Community Packages: ENABLED βœ…"' >> /start.sh && \
106
- echo 'echo " - Authentication: DISABLED βœ…"' >> /start.sh && \
107
- echo 'echo ""' >> /start.sh && \
108
- echo '' >> /start.sh && \
109
- echo '# Skip database check and start directly' >> /start.sh && \
110
- echo 'echo "πŸ”„ Skipping database connection check..."' >> /start.sh && \
111
- echo 'echo "⚠️ Database will be tested when n8n starts"' >> /start.sh && \
112
- echo '' >> /start.sh && \
113
  echo 'echo "🎯 Starting n8n server..."' >> /start.sh && \
114
- echo 'exec n8n start' >> /start.sh
 
115
 
116
  # Make script executable
117
  RUN chmod +x /start.sh
118
 
119
- # Set working directory
120
- WORKDIR /home/node
121
 
122
  # Expose port for Hugging Face Spaces
123
  EXPOSE 7860
 
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
 
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
+ # 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
  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