优化下载速度, 配置镜像站
This commit is contained in:
@@ -45,6 +45,23 @@ docker compose build
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
当前 Dockerfile 已默认针对国内服务器优化以下下载源:
|
||||
|
||||
- Debian `apt` 使用腾讯云镜像
|
||||
- `npm` 使用 `npmmirror`
|
||||
- Playwright 浏览器下载在 `amd64` 下默认使用 `npmmirror`,其他架构回退官方源
|
||||
- `uv` / `pip` 使用腾讯云 PyPI 镜像
|
||||
|
||||
如果你的服务器网络环境不同,也可以在构建时覆盖:
|
||||
|
||||
```bash
|
||||
docker compose build \
|
||||
--build-arg DEBIAN_MIRROR=mirrors.tuna.tsinghua.edu.cn \
|
||||
--build-arg NPM_REGISTRY=https://registry.npmjs.org \
|
||||
--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://playwright.azureedge.net \
|
||||
--build-arg UV_DEFAULT_INDEX=https://pypi.org/simple
|
||||
```
|
||||
|
||||
默认入口:
|
||||
|
||||
- 前端与领取页:`https://你的域名/`
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
FROM node:22-bookworm
|
||||
|
||||
ARG DEBIAN_MIRROR=mirrors.cloud.tencent.com
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
ARG PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright
|
||||
ARG UV_DEFAULT_INDEX=https://mirrors.cloud.tencent.com/pypi/simple
|
||||
ARG TARGETARCH
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
||||
ENV UV_LINK_MODE=copy
|
||||
ENV UV_DEFAULT_INDEX=${UV_DEFAULT_INDEX}
|
||||
ENV PIP_INDEX_URL=${UV_DEFAULT_INDEX}
|
||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN sed -i "s|http://deb.debian.org/debian|https://${DEBIAN_MIRROR}/debian|g" /etc/apt/sources.list.d/debian.sources \
|
||||
&& sed -i "s|http://security.debian.org/debian-security|https://${DEBIAN_MIRROR}/debian-security|g" /etc/apt/sources.list.d/debian.sources
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends curl ca-certificates python3 python3-pip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -16,7 +28,11 @@ RUN curl -LsSf https://astral.sh/uv/install.sh | sh \
|
||||
COPY apps/backend/package.json apps/backend/package-lock.json ./
|
||||
RUN npm ci
|
||||
|
||||
RUN npx playwright install --with-deps chromium
|
||||
RUN if [ "${TARGETARCH}" = "amd64" ]; then \
|
||||
PLAYWRIGHT_DOWNLOAD_HOST="${PLAYWRIGHT_DOWNLOAD_HOST}" npx playwright install --with-deps chromium; \
|
||||
else \
|
||||
npx playwright install --with-deps chromium; \
|
||||
fi
|
||||
|
||||
COPY apps/backend/ ./
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
FROM node:22-bookworm AS builder
|
||||
|
||||
ARG NPM_REGISTRY=https://registry.npmmirror.com
|
||||
|
||||
ENV NPM_CONFIG_REGISTRY=${NPM_REGISTRY}
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY apps/frontend/package.json apps/frontend/package-lock.json ./
|
||||
|
||||
@@ -74,6 +74,24 @@ docker compose build
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
如果服务器在国内,当前版本默认已启用国内镜像源加速:
|
||||
|
||||
- Debian `apt`:腾讯云镜像
|
||||
- `npm`:`npmmirror`
|
||||
- Playwright:`amd64` 默认走 `npmmirror`,其他架构自动回退官方源
|
||||
- `uv` / `pip`:腾讯云 PyPI 镜像
|
||||
|
||||
如果你要切换成别的源,可以手动执行:
|
||||
|
||||
```bash
|
||||
docker compose build \
|
||||
--build-arg DEBIAN_MIRROR=mirrors.tuna.tsinghua.edu.cn \
|
||||
--build-arg NPM_REGISTRY=https://registry.npmmirror.com \
|
||||
--build-arg PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright \
|
||||
--build-arg UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
查看运行状态:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user