Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +18 -15
Dockerfile
CHANGED
@@ -1,23 +1,26 @@
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
-
#
|
4 |
-
|
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 --
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
#
|
20 |
-
COPY
|
21 |
|
22 |
-
#
|
23 |
-
|
|
|
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"]
|