geqintan commited on
Commit
8e3b547
·
1 Parent(s): cff69b3
Files changed (1) hide show
  1. Dockerfile +19 -9
Dockerfile CHANGED
@@ -1,22 +1,32 @@
1
  FROM ubuntu:20.04
2
 
 
 
 
 
 
 
3
  # 安装 Node.js 18.x
4
- RUN apt-get update && apt-get install -y curl ca-certificates
5
- RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
6
- RUN apt-get install -y nodejs
7
 
8
- # 配置 npm 镜像源(可选)
9
- # RUN npm config set registry https://registry.npmmirror.com
10
 
11
  # 全局安装 n8n
12
  RUN npm install -g n8n
13
 
14
- # 适配 Hugging Face Spaces 端口
 
 
 
 
 
 
 
 
15
  ENV PORT=7860
16
  EXPOSE 7860
17
 
18
- # 持久化数据卷
19
- VOLUME /root/.n8n
20
-
21
  # 启动命令
22
  CMD ["n8n", "start", "--port", "7860"]
 
1
  FROM ubuntu:20.04
2
 
3
+ # 安装基础依赖
4
+ RUN apt-get update && apt-get install -y curl ca-certificates openssl
5
+
6
+ # 创建非 root 用户
7
+ RUN useradd -m -d /home/node -s /bin/bash node
8
+
9
  # 安装 Node.js 18.x
10
+ RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \
11
+ apt-get install -y nodejs
 
12
 
13
+ # 配置 npm 镜像源
14
+ RUN npm config set registry https://registry.npmmirror.com
15
 
16
  # 全局安装 n8n
17
  RUN npm install -g n8n
18
 
19
+ # 切换到非 root 用户并设置环境
20
+ USER node
21
+ ENV HOME=/home/node
22
+ WORKDIR $HOME/app
23
+
24
+ # 持久化存储配置
25
+ VOLUME $HOME/.n8n
26
+
27
+ # 适配 Hugging Face Spaces
28
  ENV PORT=7860
29
  EXPOSE 7860
30
 
 
 
 
31
  # 启动命令
32
  CMD ["n8n", "start", "--port", "7860"]