chore(docker): optimize build with domestic mirrors
Replace ghcr.io/astral-sh/uv with pip install using aliyun mirror to prevent hanging. Also configure npm and uv to use domestic registry/mirror.
This commit is contained in:
parent
80a4c5f6ad
commit
f55bc70fde
14
Dockerfile
14
Dockerfile
|
|
@ -1,12 +1,13 @@
|
|||
FROM python:3.11
|
||||
|
||||
# 安装 Node.js (满足 >=18)及必要工具
|
||||
RUN apt-get update \
|
||||
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends nodejs npm \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 从 uv 官方镜像复制 uv
|
||||
COPY --from=ghcr.io/astral-sh/uv:0.9.26 /uv /uvx /bin/
|
||||
# 通过 pip 安装 uv(替代直接拉取 ghcr.io 官方镜像,避免国内网络卡顿)
|
||||
RUN pip install -i https://mirrors.aliyun.com/pypi/simple/ uv
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
|
@ -15,10 +16,11 @@ COPY package.json package-lock.json ./
|
|||
COPY frontend/package.json frontend/package-lock.json ./frontend/
|
||||
COPY backend/pyproject.toml backend/uv.lock ./backend/
|
||||
|
||||
# 安装依赖(Node + Python)
|
||||
RUN npm ci \
|
||||
# 安装依赖(Node + Python),配置国内加速源
|
||||
RUN npm config set registry https://registry.npmmirror.com \
|
||||
&& npm ci \
|
||||
&& npm ci --prefix frontend \
|
||||
&& cd backend && uv sync --frozen
|
||||
&& cd backend && env UV_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ uv sync --frozen
|
||||
|
||||
# 复制项目源码
|
||||
COPY . .
|
||||
|
|
|
|||
Loading…
Reference in New Issue