Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +10 -24
Dockerfile
CHANGED
@@ -1,32 +1,18 @@
|
|
1 |
-
FROM python:3.10-slim
|
2 |
|
3 |
-
#
|
4 |
ENV TRANSFORMERS_CACHE=/model-cache \
|
5 |
-
PYTHONUNBUFFERED=1
|
6 |
-
PATH="/home/appuser/.local/bin:${PATH}"
|
7 |
|
8 |
-
#
|
9 |
-
RUN
|
10 |
-
apt-get install -y --no-install-recommends gcc python3-dev && \
|
11 |
-
rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
-
#
|
14 |
-
RUN
|
15 |
-
mkdir -p /model-cache && \
|
16 |
-
chown -R appuser:appuser /model-cache
|
17 |
|
18 |
-
# 切换用户
|
19 |
-
USER appuser
|
20 |
WORKDIR /app
|
|
|
21 |
|
22 |
-
|
23 |
-
COPY requirements.txt .
|
24 |
-
RUN pip install --no-cache-dir --upgrade pip && \
|
25 |
-
pip install --no-cache-dir gunicorn==21.2.0 && \ # 显式安装gunicorn
|
26 |
-
pip install --no-cache-dir -r requirements.txt
|
27 |
|
28 |
-
|
29 |
-
COPY app.py .
|
30 |
-
|
31 |
-
EXPOSE 8080
|
32 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "--timeout", "120", "app:app"]
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
|
3 |
+
# 显式声明环境变量(与huggingface配置同步)
|
4 |
ENV TRANSFORMERS_CACHE=/model-cache \
|
5 |
+
PYTHONUNBUFFERED=1
|
|
|
6 |
|
7 |
+
# 创建缓存目录
|
8 |
+
RUN mkdir -p /model-cache && chmod 777 /model-cache
|
|
|
|
|
9 |
|
10 |
+
# 安装依赖
|
11 |
+
RUN apt-get update && apt-get install -y gcc python3-dev
|
|
|
|
|
12 |
|
|
|
|
|
13 |
WORKDIR /app
|
14 |
+
COPY . .
|
15 |
|
16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:8080", "app:app"]
|
|
|
|
|
|
|
|