guoj5 commited on
Commit
99c87de
·
1 Parent(s): 5ddb215

Dockerfile revised

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -14
Dockerfile CHANGED
@@ -1,23 +1,27 @@
1
- # 使用官方 Python 3.13
2
  FROM python:3.13
3
 
4
- # 创建一个非root用户 (Hugging Face官方示例里常见)
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
- USER user
7
 
8
- # ~/.local/bin 加进 PATH,便于 pip 安装脚本等
9
- ENV PATH="/home/user/.local/bin:$PATH"
10
 
11
- # 切换到 /app 目录
12
- WORKDIR /app
 
13
 
14
- # 先复制 requirements.txt 并安装依赖
15
- COPY requirements.txt .
16
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
17
 
18
- # 再把当前所有代码复制到 /app
19
- # (此时已含你编译好的前端文件,位于你的 backend/static/ 下)
20
- COPY . /app
21
 
22
- # 最终启动命令:监听 0.0.0.0:7860
23
  CMD ["python", "backend/app.py", "--host=0.0.0.0", "--port", "7860"]
 
1
+ # Python 3.13
2
  FROM python:3.13
3
 
4
+ WORKDIR /code
5
+
6
+ COPY ./requirements.txt /code/requirements.txt
7
+
8
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
9
+
10
+ # Set up a new user named "user" with user ID 1000
11
  RUN useradd -m -u 1000 user
 
12
 
13
+ # Switch to the "user" user
14
+ USER user
15
 
16
+ # Set home to the user's home directory
17
+ ENV HOME=/home/user \
18
+ PATH=/home/user/.local/bin:$PATH
19
 
20
+ # Set the working directory to the user's home directory
21
+ WORKDIR $HOME/app
 
22
 
23
+ # Copy the current directory contents into the container at $HOME/app setting the owner to the user
24
+ COPY --chown=user . $HOME/app
 
25
 
26
+ # Listen 0.0.0.0:7860
27
  CMD ["python", "backend/app.py", "--host=0.0.0.0", "--port", "7860"]