Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +16 -5
Dockerfile
CHANGED
|
@@ -39,9 +39,13 @@ RUN apt-get update && \
|
|
| 39 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
| 40 |
pip install --no-cache-dir --upgrade pip
|
| 41 |
|
| 42 |
-
#
|
| 43 |
WORKDIR /app
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 46 |
|
| 47 |
# 安装 huggingface_hub
|
|
@@ -50,14 +54,21 @@ RUN pip install --no-cache-dir huggingface_hub
|
|
| 50 |
# 创建应用目录
|
| 51 |
RUN mkdir account templates static
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
COPY run.py .
|
| 55 |
-
COPY utils/ ./utils/
|
| 56 |
|
| 57 |
# 从前端构建阶段复制构建产物
|
| 58 |
COPY --from=frontend-builder /app/frontend/dist/index.html ./templates/
|
| 59 |
COPY --from=frontend-builder /app/frontend/dist/* ./static/
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
# 暴露端口 5000
|
| 62 |
EXPOSE 5000
|
| 63 |
|
|
|
|
| 39 |
RUN python3 -m venv $VIRTUAL_ENV && \
|
| 40 |
pip install --no-cache-dir --upgrade pip
|
| 41 |
|
| 42 |
+
# 设置工作目录
|
| 43 |
WORKDIR /app
|
| 44 |
+
|
| 45 |
+
# 从 frontend-builder 阶段复制 requirements.txt
|
| 46 |
+
COPY --from=frontend-builder /app/requirements.txt .
|
| 47 |
+
|
| 48 |
+
# 安装 Python 依赖
|
| 49 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 50 |
|
| 51 |
# 安装 huggingface_hub
|
|
|
|
| 54 |
# 创建应用目录
|
| 55 |
RUN mkdir account templates static
|
| 56 |
|
| 57 |
+
# 从 frontend-builder 阶段复制后端源文件
|
| 58 |
+
COPY --from=frontend-builder /app/run.py .
|
| 59 |
+
COPY --from=frontend-builder /app/utils/ ./utils/
|
| 60 |
|
| 61 |
# 从前端构建阶段复制构建产物
|
| 62 |
COPY --from=frontend-builder /app/frontend/dist/index.html ./templates/
|
| 63 |
COPY --from=frontend-builder /app/frontend/dist/* ./static/
|
| 64 |
|
| 65 |
+
# 创建非 root 用户
|
| 66 |
+
RUN useradd -m -u 1000 appuser && \
|
| 67 |
+
chown -R appuser:appuser /app
|
| 68 |
+
|
| 69 |
+
# 切换到非 root 用户
|
| 70 |
+
USER appuser
|
| 71 |
+
|
| 72 |
# 暴露端口 5000
|
| 73 |
EXPOSE 5000
|
| 74 |
|