Forrest99 commited on
Commit
a26e689
·
verified ·
1 Parent(s): 5b492ea

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -15
Dockerfile CHANGED
@@ -1,23 +1,26 @@
1
  FROM python:3.9-slim
2
 
3
- # 设置缓存目录路径(统一路径便于管理)
4
- ENV HF_HOME=/app/.cache/huggingface
5
- ENV TRANSFORMERS_CACHE=$HF_HOME
6
-
7
- # 创建专用用户并设置权限
8
- RUN useradd -m -u 1000 appuser && \
9
- mkdir -p $HF_HOME && \
10
- chown -R appuser:appuser /app
11
 
 
12
  WORKDIR /app
13
- USER appuser
14
 
15
- # 高效安装依赖
 
 
 
 
 
16
  COPY requirements.txt .
17
- RUN pip install --user --no-cache-dir -r requirements.txt
 
 
 
 
18
 
19
- # 复制应用代码(排除无关文件)
20
- COPY app.py ./
21
 
22
- # Hugging Face Spaces专用端口配置
23
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM python:3.9-slim
2
 
3
+ # 创建专用用户
4
+ RUN useradd -m -u 1000 appuser
 
 
 
 
 
 
5
 
6
+ # 设置工作目录
7
  WORKDIR /app
 
8
 
9
+ # 安装系统依赖
10
+ RUN apt-get update && apt-get install -y --no-install-recommends \
11
+ gcc python3-dev && \
12
+ rm -rf /var/lib/apt/lists/*
13
+
14
+ # 全局安装依赖
15
  COPY requirements.txt .
16
+ RUN pip install --no-cache-dir -r requirements.txt
17
+
18
+ # 设置权限
19
+ RUN chown -R appuser:appuser /app
20
+ USER appuser
21
 
22
+ # 复制代码
23
+ COPY --chown=appuser:appuser . .
24
 
25
+ # 设置容器入口
26
+ ENTRYPOINT ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]