Spaces:
Configuration error
Configuration error
Create Dockerfile
Browse files- Dockerfile +35 -0
Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 使用官方Python 3.10 slim镜像
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# --- 1. [核心修复] 安装核心系统依赖 ---
|
| 5 |
+
# 更新包列表,并安装一些torch和sentence-transformers可能需要的底层库
|
| 6 |
+
# libgomp1 是OpenMP库,对于并行计算很重要
|
| 7 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 8 |
+
git \
|
| 9 |
+
build-essential \
|
| 10 |
+
libgomp1 \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# --- 2. 关键步骤:克隆私有仓库 ---
|
| 14 |
+
WORKDIR /src
|
| 15 |
+
RUN --mount=type=secret,id=GH_USER \
|
| 16 |
+
--mount=type=secret,id=GH_TOKEN \
|
| 17 |
+
git clone https://$(cat /run/secrets/GH_USER):$(cat /run/secrets/GH_TOKEN)@github.com/leoncool23/tcm_expert_builder.git
|
| 18 |
+
|
| 19 |
+
# --- 3. 设置正确的工作目录 ---
|
| 20 |
+
WORKDIR /src/tcm_expert_builder
|
| 21 |
+
|
| 22 |
+
# --- 4. 设置Python环境 ---
|
| 23 |
+
# 复制 requirements.txt 文件并安装
|
| 24 |
+
# COPY requirements.txt . <-- This line is not needed as git clone already does it
|
| 25 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 26 |
+
|
| 27 |
+
# --- 5. 创建应用所需目录并设置权限 ---
|
| 28 |
+
RUN useradd --create-home --shell /bin/bash appuser
|
| 29 |
+
RUN mkdir -p ./uploads ./data/vector_db
|
| 30 |
+
RUN chown -R appuser:appuser .
|
| 31 |
+
USER appuser
|
| 32 |
+
|
| 33 |
+
# --- 6. 运行应用 ---
|
| 34 |
+
EXPOSE 7860
|
| 35 |
+
CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:7860", "app:app"]
|