支持 MySQL 迁移与性能优化
This commit is contained in:
+30
-15
@@ -13,38 +13,53 @@ RUN npm run build
|
||||
# ===== 阶段2: Python 运行时 =====
|
||||
FROM python:3.12-slim AS runtime
|
||||
|
||||
# 优先阿里云内网镜像,其次公网阿里云,最后官方源。
|
||||
RUN cp /etc/apt/sources.list.d/debian.sources /tmp/debian.sources && \
|
||||
sed -i 's/deb.debian.org/mirrors.cloud.aliyuncs.com/g' /etc/apt/sources.list.d/debian.sources && \
|
||||
(apt-get update -o APT::Update::Error-Mode=any || \
|
||||
(sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update -o APT::Update::Error-Mode=any) || \
|
||||
(cp /tmp/debian.sources /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update -o APT::Update::Error-Mode=any)) && \
|
||||
ARG USE_CHINA_MIRRORS=true
|
||||
|
||||
# 服务器默认使用阿里云镜像;本地构建可设 USE_CHINA_MIRRORS=false 直连官方源。
|
||||
RUN if [ "$USE_CHINA_MIRRORS" = "true" ]; then \
|
||||
cp /etc/apt/sources.list.d/debian.sources /tmp/debian.sources && \
|
||||
sed -i 's/deb.debian.org/mirrors.cloud.aliyuncs.com/g' /etc/apt/sources.list.d/debian.sources && \
|
||||
(apt-get update -o APT::Update::Error-Mode=any || \
|
||||
(sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update -o APT::Update::Error-Mode=any) || \
|
||||
(cp /tmp/debian.sources /etc/apt/sources.list.d/debian.sources && \
|
||||
apt-get update -o APT::Update::Error-Mode=any)); \
|
||||
else \
|
||||
apt-get update -o APT::Update::Error-Mode=any; \
|
||||
fi && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
nodejs \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 安装 uv:优先阿里云内网 PyPI → 公网阿里云 → 官方。
|
||||
RUN pip install -i https://mirrors.cloud.aliyuncs.com/pypi/simple/ uv || \
|
||||
pip install -i https://mirrors.aliyun.com/pypi/simple/ uv || \
|
||||
pip install uv
|
||||
# 安装 uv:服务器走阿里云镜像,本地直连官方 PyPI。
|
||||
RUN if [ "$USE_CHINA_MIRRORS" = "true" ]; then \
|
||||
pip install -i https://mirrors.cloud.aliyuncs.com/pypi/simple/ uv || \
|
||||
pip install -i https://mirrors.aliyun.com/pypi/simple/ uv || \
|
||||
pip install uv; \
|
||||
else \
|
||||
pip install uv; \
|
||||
fi
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 先复制依赖文件,利用 Docker 缓存层
|
||||
COPY pyproject.toml uv.lock* README.md alembic.ini ./
|
||||
RUN uv venv /app/.venv && \
|
||||
(UV_INDEX_URL=https://mirrors.cloud.aliyuncs.com/pypi/simple/ uv pip install -e . || \
|
||||
UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ uv pip install -e . || \
|
||||
uv pip install -e .)
|
||||
if [ "$USE_CHINA_MIRRORS" = "true" ]; then \
|
||||
(UV_INDEX_URL=https://mirrors.cloud.aliyuncs.com/pypi/simple/ uv pip install -e . || \
|
||||
UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ uv pip install -e . || \
|
||||
uv pip install -e .); \
|
||||
else \
|
||||
uv pip install -e .; \
|
||||
fi
|
||||
|
||||
# 复制项目代码
|
||||
COPY core/ ./core/
|
||||
COPY utils/ ./utils/
|
||||
COPY web/backend/ ./web/backend/
|
||||
COPY scripts/ ./scripts/
|
||||
|
||||
# 复制前端构建产物
|
||||
COPY --from=frontend-builder /build/dist ./web/frontend/dist
|
||||
|
||||
Reference in New Issue
Block a user