Subham9126 commited on
Commit
d293d21
·
verified ·
1 Parent(s): e3820a1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -15
Dockerfile CHANGED
@@ -1,30 +1,32 @@
1
- # Use the naskio image for built-in Python
2
  FROM naskio/n8n-python:2.13.0
3
  LABEL maintainer="Xiaoliang <xiaoliang.zero@gmail.com>"
4
 
5
- # 1. We must stay as USER node for HF Spaces compatibility
6
- # We do NOT use 'USER root' to avoid 'su-exec' or 'chown' errors at runtime
 
 
 
 
 
 
 
 
 
7
  USER node
8
 
9
- # 2. Environment Configuration for HF Spaces
10
- # - N8N_PYTHON_BINARY: Points to the Python path
11
- # - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS: Set to false to stop n8n from trying to chown files
12
- # - N8N_PORT: HF Spaces listens on 7860
13
- # - N8N_RUNNERS_PY_PACKAGES: Auto-installs your libraries
14
  ENV N8N_PYTHON_BINARY=/usr/bin/python3 \
15
  N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false \
16
  N8N_PORT=7860 \
17
- N8N_PROXY_HOPS=1 \
18
- NODE_FUNCTION_ALLOW_EXTERNAL="*" \
 
 
19
  N8N_RUNNERS_PY_PACKAGES="pandas numpy requests" \
20
  HOME=/home/node
21
 
22
- # 3. Set the working directory to the user's home
23
  WORKDIR /home/node
24
-
25
- # 4. Expose the HF Space port
26
  EXPOSE 7860
27
 
28
- # 5. Overwrite the entrypoint
29
- # We call n8n directly instead of using the default script to avoid 'su-exec' permission errors
30
  ENTRYPOINT ["tini", "--", "n8n"]
 
 
1
  FROM naskio/n8n-python:2.13.0
2
  LABEL maintainer="Xiaoliang <xiaoliang.zero@gmail.com>"
3
 
4
+ USER root
5
+
6
+ # 1. Install venv support (required for n8n to initialize the runner)
7
+ RUN apt-get update && apt-get install -y python3-venv && rm -rf /var/lib/apt/lists/*
8
+
9
+ # 2. Pre-create the n8n Python Environment
10
+ # n8n looks for this specific path to run internal Python tasks
11
+ RUN mkdir -p /home/node/.n8n/python_envs/default && \
12
+ python3 -m venv /home/node/.n8n/python_envs/default && \
13
+ chown -R node:node /home/node/.n8n
14
+
15
  USER node
16
 
17
+ # 3. Configure n8n to use the environment we just built
 
 
 
 
18
  ENV N8N_PYTHON_BINARY=/usr/bin/python3 \
19
  N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=false \
20
  N8N_PORT=7860 \
21
+ N8N_RUNNERS_ENABLED=true \
22
+ # Point n8n to the venv we created in step 2
23
+ N8N_RUNNERS_PY_VENV_PATH=/home/node/.n8n/python_envs/default \
24
+ # Add your required libraries here
25
  N8N_RUNNERS_PY_PACKAGES="pandas numpy requests" \
26
  HOME=/home/node
27
 
 
28
  WORKDIR /home/node
 
 
29
  EXPOSE 7860
30
 
31
+ # Direct execution to bypass the su-exec/chown script
 
32
  ENTRYPOINT ["tini", "--", "n8n"]