legends810 commited on
Commit
9a13398
Β·
verified Β·
1 Parent(s): e502fe2

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +131 -0
Dockerfile ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
+ RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH \
41
+ && chmod -R 777 $BASE_PATH
42
+
43
+ # Hugging Face Spaces specific settings
44
+ ENV N8N_PORT=7860
45
+ ENV N8N_HOST=0.0.0.0
46
+ ENV N8N_PROTOCOL=https
47
+
48
+ # Database configuration (PostgreSQL)
49
+ ENV DB_TYPE=postgresdb
50
+ ENV DB_POSTGRESDB_HOST=dpg-d24698qli9vc73ccu71g-a
51
+ ENV DB_POSTGRESDB_DATABASE=rabu
52
+ ENV DB_POSTGRESDB_USER=rabu_user
53
+ ENV DB_POSTGRESDB_PASSWORD=dA6RI6SPr3gEWoTz5lgctjzjmZ3jAmxk
54
+ ENV DB_POSTGRESDB_SSL=true
55
+ ENV DB_POSTGRESDB_PORT=5432
56
+
57
+ # Community packages enable ΰ€•ΰ€°ΰ₯‡ΰ€‚
58
+ ENV N8N_COMMUNITY_PACKAGES_ENABLED=true
59
+ ENV N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true
60
+
61
+ # MOST IMPORTANT: gzip compression disable ΰ€•ΰ€°ΰ₯‡ΰ€‚ (ΰ€†ΰ€ͺΰ€•ΰ₯€ main problem ΰ€•ΰ€Ύ solution)
62
+ ENV COMPRESSION_ENABLED=false
63
+ ENV N8N_DISABLE_GZIP=true
64
+ ENV N8N_DISABLE_PRODUCTION_MAIN_PROCESS_RESPONSE_COMPRESSION=true
65
+ ENV DISABLE_COMPRESSION=true
66
+ ENV NODE_OPTIONS="--max-old-space-size=4096"
67
+
68
+ # NO AUTHENTICATION
69
+ ENV N8N_BASIC_AUTH_ACTIVE=false
70
+ ENV N8N_USER_MANAGEMENT_DISABLED=true
71
+
72
+ # Performance settings
73
+ ENV N8N_LOG_LEVEL=info
74
+ ENV N8N_DISABLE_PRODUCTION_MAIN_PROCESS=false
75
+
76
+ # Create startup script with URL display
77
+ RUN cat > /start.sh << 'EOF'
78
+ #!/bin/bash
79
+
80
+ echo "πŸš€ ===== n8n Starting on Hugging Face Spaces ====="
81
+
82
+ # Dynamic URL detection
83
+ if [ -n "$SPACE_ID" ]; then
84
+ APP_URL="https://$SPACE_ID.hf.space"
85
+ elif [ -n "$SPACE_HOST" ]; then
86
+ APP_URL="https://$SPACE_HOST"
87
+ else
88
+ APP_URL="http://localhost:7860"
89
+ fi
90
+
91
+ # Set dynamic URLs
92
+ export N8N_BASE_URL="$APP_URL/"
93
+ export WEBHOOK_URL="$APP_URL/"
94
+ export N8N_EDITOR_BASE_URL="$APP_URL"
95
+
96
+ echo "🌐 n8n will be available at: $APP_URL"
97
+ echo "πŸ“Š Configuration:"
98
+ echo " - Port: $N8N_PORT"
99
+ echo " - Database: PostgreSQL"
100
+ echo " - Compression: DISABLED βœ…"
101
+ echo " - Community Packages: ENABLED βœ…"
102
+ echo " - Authentication: DISABLED βœ…"
103
+ echo ""
104
+
105
+ # Wait for database connection
106
+ echo "πŸ”„ Checking database connection..."
107
+ until pg_isready -h $DB_POSTGRESDB_HOST -p $DB_POSTGRESDB_PORT -U $DB_POSTGRESDB_USER; do
108
+ echo "⏳ Waiting for database..."
109
+ sleep 2
110
+ done
111
+ echo "βœ… Database connected!"
112
+
113
+ echo "🎯 Starting n8n server..."
114
+ exec n8n start
115
+ EOF
116
+
117
+ # Make script executable
118
+ RUN chmod +x /start.sh
119
+
120
+ # Set working directory
121
+ WORKDIR /home/node
122
+
123
+ # Expose port for Hugging Face Spaces
124
+ EXPOSE 7860
125
+
126
+ # Health check
127
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=45s --retries=3 \
128
+ CMD curl -f http://localhost:7860/healthz || curl -f http://localhost:7860/ || exit 1
129
+
130
+ # Use custom startup script
131
+ CMD ["/start.sh"]