web525 commited on
Commit
8bedd57
·
1 Parent(s): 2e8a42b
Files changed (2) hide show
  1. Dockerfile +22 -14
  2. start.sh +2 -2
Dockerfile CHANGED
@@ -1,25 +1,33 @@
 
1
  FROM chaoszhu/easynode:latest
2
 
3
- # 创建用户避免权限问题(Hugging Face要求)
4
- RUN useradd -m -u 1000 user
5
- USER user
6
- ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
7
- WORKDIR $HOME/app
8
 
9
- # 创建数据目录
10
- RUN mkdir -p $HOME/app/db
 
11
 
12
- # 修改EasyNode监听端口为7860(Hugging Face默认端口)
13
- ENV PORT=7860
 
14
 
15
- # 使用Nginx反向代理解决多端口问题
16
- USER root
17
- RUN apt-get update && apt-get install -y nginx
18
- COPY nginx.conf /etc/nginx/nginx.conf
19
 
20
- # 启动脚本
 
21
  COPY start.sh /start.sh
22
  RUN chmod +x /start.sh
23
 
 
 
 
 
 
24
  EXPOSE 7860
 
 
25
  CMD ["/start.sh"]
 
1
+ # 使用EasyNode官方镜像
2
  FROM chaoszhu/easynode:latest
3
 
4
+ # 切换到root用户进行系统配置
5
+ USER root
 
 
 
6
 
7
+ # 1. 修复:Alpine使用adduser而非useradd
8
+ # 创建非root用户(Hugging Face Spaces强制要求)
9
+ RUN adduser -D -u 1000 user
10
 
11
+ # 2. 为Alpine安装必要的依赖
12
+ RUN apk update && \
13
+ apk add --no-cache nginx bash
14
 
15
+ # 3. 创建应用目录并设置权限
16
+ RUN mkdir -p /home/user/app/db && \
17
+ chown -R user:user /home/user && \
18
+ chown -R user:user /easynode/app/db
19
 
20
+ # 4. 创建配置文件
21
+ COPY nginx.conf /etc/nginx/nginx.conf
22
  COPY start.sh /start.sh
23
  RUN chmod +x /start.sh
24
 
25
+ # 5. 切换回非root用户
26
+ USER user
27
+ WORKDIR /home/user/app
28
+
29
+ # 暴露Hugging Face要求的端口
30
  EXPOSE 7860
31
+
32
+ # 启动命令
33
  CMD ["/start.sh"]
start.sh CHANGED
@@ -1,5 +1,5 @@
1
  #!/bin/bash
2
- # 启动EasyNode(修改端口为8082)
3
  node /easynode/app/index.js --port 8082 &
4
- # 启动Nginx
5
  nginx -g "daemon off;"
 
1
  #!/bin/bash
2
+ # 启动EasyNode(在后台运行,使用8082端口)
3
  node /easynode/app/index.js --port 8082 &
4
+ # 启动Nginx(前台运行)
5
  nginx -g "daemon off;"