2026-07-21 09:23:43 +08:00
|
|
|
|
FROM python:3.12-slim
|
2026-07-20 14:59:31 +08:00
|
|
|
|
|
|
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
|
|
|
|
PYTHONUNBUFFERED=1 \
|
2026-08-11 14:17:45 +08:00
|
|
|
|
PIP_NO_CACHE_DIR=1 \
|
|
|
|
|
|
TIKTOKEN_CACHE_DIR=/opt/tiktoken_cache
|
2026-07-20 14:59:31 +08:00
|
|
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
COPY backend/requirements.txt /tmp/requirements.txt
|
2026-07-21 12:45:47 +08:00
|
|
|
|
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
|
|
|
|
|
&& pip install -r /tmp/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple \
|
2026-07-20 14:59:31 +08:00
|
|
|
|
&& rm -f /tmp/requirements.txt
|
|
|
|
|
|
|
2026-08-11 16:25:18 +08:00
|
|
|
|
RUN python -c "import fastapi, uvicorn, psycopg, psycopg_pool, sqlalchemy, redis, jwt, passlib, httpx, minio, alembic; print('backend dependency check ok')"
|
2026-07-21 11:36:43 +08:00
|
|
|
|
|
2026-08-21 10:15:08 +08:00
|
|
|
|
RUN mkdir -p /opt/yg-ft/logs/backend /data/yg-ft /opt/tiktoken_cache \
|
|
|
|
|
|
&& chmod -R 0775 /opt/yg-ft /data/yg-ft /opt/tiktoken_cache
|
2026-07-20 14:59:31 +08:00
|
|
|
|
|
2026-08-21 10:15:08 +08:00
|
|
|
|
# 离线打包 tiktoken cl100k_base 词表(与运行时 TIKTOKEN_CACHE_DIR 对齐),
|
|
|
|
|
|
# 文件名采用官方 SHA,避免代码走 fallback 重建 Encoding 的分支。
|
|
|
|
|
|
COPY docker/app/tiktoken/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 /opt/tiktoken_cache/
|
2026-08-11 14:17:45 +08:00
|
|
|
|
|
2026-07-20 14:59:31 +08:00
|
|
|
|
EXPOSE 8000
|
|
|
|
|
|
|
|
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|