Forrest99 commited on
Commit
47336a8
·
verified ·
1 Parent(s): e982705

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -1
Dockerfile CHANGED
@@ -1,8 +1,19 @@
1
  # 使用官方 Python 镜像
2
  FROM python:3.9-slim
3
 
4
- # 设置工作目录
 
 
 
 
 
 
 
 
5
  WORKDIR /app
 
 
 
6
 
7
  # 安装依赖
8
  COPY requirements.txt .
 
1
  # 使用官方 Python 镜像
2
  FROM python:3.9-slim
3
 
4
+ # 设置缓存目录(必须用 root 用户创建)
5
+ RUN mkdir -p /app/.cache/huggingface && \
6
+ chmod 777 /app /app/.cache /app/.cache/huggingface
7
+
8
+ # 创建非 root 用户并切换
9
+ RUN useradd -m -u 1000 appuser
10
+ USER appuser
11
+
12
+ # 设置工作目录和环境变量
13
  WORKDIR /app
14
+ ENV HF_HOME=/app/.cache/huggingface \
15
+ TRANSFORMERS_CACHE=/app/.cache/huggingface \
16
+ HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface
17
 
18
  # 安装依赖
19
  COPY requirements.txt .