malekradwan130 commited on
Commit
f56a61c
·
verified ·
1 Parent(s): 3614979

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +57 -16
Dockerfile CHANGED
@@ -1,9 +1,22 @@
1
  FROM node:24-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
@@ -11,7 +24,9 @@ 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 (for Web automation, databases, video processing)
 
 
15
  RUN apk add --no-cache \
16
  git \
17
  python3 \
@@ -30,30 +45,56 @@ RUN apk add --no-cache \
30
  curl \
31
  bash \
32
  unzip \
33
- libaio
 
 
 
 
 
 
 
 
 
34
 
35
- # Puppeteer/Chromium configuration
 
 
36
  ENV PUPPETEER_SKIP_DOWNLOAD=true
37
  ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
38
 
39
- # Install n8n globally (will install the latest stable version)
 
 
40
  RUN npm install -g n8n
41
 
42
- # Create necessary directories
 
 
43
  RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH
44
 
45
- # Set ownership to the 'node' user for security
46
- RUN chown -R node:node $BASE_PATH
 
 
 
 
47
 
48
- # Set owner and fix write permission for the working directory
49
- RUN mkdir -p /data \
50
- && chown -R node:node /data
51
-
52
- # Set working directory
53
  WORKDIR /data
54
 
55
- # Switch to non-root user for execution (CRITICAL FOR SECURITY)
 
 
56
  USER node
57
 
 
 
 
 
 
 
58
  # Start n8n
59
- CMD ["n8n", "start"]
 
 
1
  FROM node:24-alpine
2
 
3
+ # =========================
4
+ # Root for setup
5
+ # =========================
6
  USER root
7
 
8
+ # -------------------------
9
+ # DNS / Network tweaks (BEST EFFORT)
10
+ # -------------------------
11
+ # Force IPv4 first (very important for Node on HF)
12
+ ENV NODE_OPTIONS=--dns-result-order=ipv4first
13
+
14
+ # Optional: reduce TLS strictness for testing (does NOT fix ENOTFOUND)
15
+ ENV NODE_TLS_REJECT_UNAUTHORIZED=0
16
+
17
+ # -------------------------
18
+ # n8n paths
19
+ # -------------------------
20
  ARG N8N_PATH=/usr/local/lib/node_modules/n8n
21
  ARG BASE_PATH=/root/.n8n
22
  ARG DATABASE_PATH=$BASE_PATH/database
 
24
  ARG WORKFLOWS_PATH=$BASE_PATH/workflows
25
  ARG LOGS_PATH=$BASE_PATH/logs
26
 
27
+ # -------------------------
28
+ # System dependencies
29
+ # -------------------------
30
  RUN apk add --no-cache \
31
  git \
32
  python3 \
 
45
  curl \
46
  bash \
47
  unzip \
48
+ libaio \
49
+ bind-tools \
50
+ ca-certificates \
51
+ && update-ca-certificates
52
+
53
+ # -------------------------
54
+ # Try overriding resolv.conf (may be overwritten by HF at runtime)
55
+ # -------------------------
56
+ RUN echo "nameserver 1.1.1.1" > /etc/resolv.conf \
57
+ && echo "nameserver 8.8.8.8" >> /etc/resolv.conf
58
 
59
+ # -------------------------
60
+ # Puppeteer / Chromium
61
+ # -------------------------
62
  ENV PUPPETEER_SKIP_DOWNLOAD=true
63
  ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
64
 
65
+ # -------------------------
66
+ # Install n8n
67
+ # -------------------------
68
  RUN npm install -g n8n
69
 
70
+ # -------------------------
71
+ # Create directories
72
+ # -------------------------
73
  RUN mkdir -p $DATABASE_PATH $CONFIG_PATH $WORKFLOWS_PATH $LOGS_PATH
74
 
75
+ # -------------------------
76
+ # Permissions
77
+ # -------------------------
78
+ RUN chown -R node:node $BASE_PATH \
79
+ && mkdir -p /data \
80
+ && chown -R node:node /data
81
 
82
+ # -------------------------
83
+ # Workdir
84
+ # -------------------------
 
 
85
  WORKDIR /data
86
 
87
+ # -------------------------
88
+ # Drop privileges
89
+ # -------------------------
90
  USER node
91
 
92
+ # -------------------------
93
+ # Optional: debug DNS at startup (TEMP – remove after test)
94
+ # -------------------------
95
+ # CMD sh -c "nslookup discord.com || true && n8n start"
96
+
97
+ # -------------------------
98
  # Start n8n
99
+ # -------------------------
100
+ CMD ["n8n", "start"]