use fast souces

This commit is contained in:
2026-10-08 11:40:52 +08:00
parent 4746331515
commit 176d722c77
8 changed files with 70 additions and 8 deletions

View File

@@ -51,6 +51,8 @@ cp -a whisper/. /opt/whisper/ # 用 whisper/. 而不是 whisper/*,否则不
cd /opt/whisper
cp .env.example .env # 按需修改 WHISPER_MODEL
# 默认从 DaoCloud 拉 ghcr 镜像;能直连 GitHub 时在 .env 里设
# WHISPER_IMAGE=ghcr.io/speaches-ai/speaches:latest-cuda
docker compose up -d
docker compose logs -f whisper # 首次启动下载模型(约 3 GB)
```
@@ -195,6 +197,33 @@ AI_MODEL=gpt-4o-mini
`http://127.0.0.1:9000/v1/audio/transcriptions`,并把 `MOSS_MODEL` 设为
`Systran/faster-whisper-large-v3`。
Dockerfile 默认使用国内镜像源,避免构建时从 Docker Hub / Debian / PyPI 直连过慢:
- 基础镜像:`docker.m.daocloud.io/library/python:3.12-slim`
- apt:`mirrors.aliyun.com`
- pip:清华 `https://pypi.tuna.tsinghua.edu.cn/simple`
如需覆盖,可在 `sentence_api/.env` 或构建命令前设置:
```bash
export PYTHON_IMAGE=python:3.12-slim # 能直连 Docker Hub 时
export PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple
export PIP_TRUSTED_HOST=mirrors.aliyun.com
export APT_MIRROR=mirrors.tuna.tsinghua.edu.cn
```
拉 Docker Hub 官方镜像仍然慢时,把仓库里的 `sentence_api/docker-daemon.json.example`
拷到 Docker 配置并重启:
```bash
sudo mkdir -p /etc/docker
sudo cp sentence_api/docker-daemon.json.example /etc/docker/daemon.json
sudo systemctl restart docker
```
`registry-mirrors` 只加速 `docker.io`。Whisper 的 `ghcr.io` 镜像请用 compose 里默认的
DaoCloud 前缀(见第 2A 节)。
启动:
```bash

View File

@@ -1,10 +1,27 @@
FROM python:3.12-slim
ARG PYTHON_IMAGE=docker.m.daocloud.io/library/python:3.12-slim
FROM ${PYTHON_IMAGE}
ARG APT_MIRROR=mirrors.aliyun.com
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
ARG PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_INDEX_URL=${PIP_INDEX_URL} \
PIP_TRUSTED_HOST=${PIP_TRUSTED_HOST}
RUN apt-get update \
RUN set -eux; \
if [ -f /etc/apt/sources.list.d/debian.sources ]; then \
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
/etc/apt/sources.list.d/debian.sources; \
fi; \
if [ -f /etc/apt/sources.list ]; then \
sed -i "s|deb.debian.org|${APT_MIRROR}|g; s|security.debian.org|${APT_MIRROR}|g" \
/etc/apt/sources.list; \
fi; \
apt-get update \
&& apt-get install -y --no-install-recommends ffmpeg ca-certificates \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -180,8 +180,8 @@ sudo systemctl restart whisper-transcribe
| 现象 | 原因 | 处理 |
| --- | --- | --- |
| 更新后接口行为没变 | 忘了 `--build`,容器还在跑旧镜像 | 执行 `docker compose up -d --build` |
| 构建时 pip 安装超时 | 服务器访问 PyPI 受限 | 给 Dockerfile 的 pip install 加 `-i https://pypi.tuna.tsinghua.edu.cn/simple` 后重新构建 |
| 构建时拉基础镜像超时 | Docker Hub 网络问题 | 检查 `/etc/docker/daemon.json` 的 `registry-mirrors`(已配置 DaoCloud) |
| 构建时 pip 安装超时 | 服务器访问 PyPI 受限 | Dockerfile 默认已用清华 PyPI;仍慢可改 `PIP_INDEX_URL` 后 `--build` |
| 构建时拉基础镜像超时 | Docker Hub 网络问题 | Dockerfile 默认从 DaoCloud 拉 `python:3.12-slim`;也可把 `docker-daemon.json.example` 拷到 `/etc/docker/daemon.json` 后 `systemctl restart docker` |
| `healthz` 里 `moss_configured: false` | `.env` 里 `MOSS_TRANSCRIBE_URL` 为空或改了未重建 | 改 `.env` 后执行 `docker compose up -d` |
| Whisper 9000 端口连不上 | 服务未运行或容器被删 | `systemctl status whisper-transcribe`;容器被删时用 `systemctl start` 重建 |
| API 重启后视频卡在 `processing` | 重启中断了处理流程 | 后台点“重新处理”即可 |

View File

@@ -3,6 +3,11 @@ services:
build:
context: ..
dockerfile: sentence_api/Dockerfile
args:
PYTHON_IMAGE: ${PYTHON_IMAGE:-docker.m.daocloud.io/library/python:3.12-slim}
APT_MIRROR: ${APT_MIRROR:-mirrors.aliyun.com}
PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple}
PIP_TRUSTED_HOST: ${PIP_TRUSTED_HOST:-pypi.tuna.tsinghua.edu.cn}
restart: unless-stopped
network_mode: host
env_file:

View File

@@ -0,0 +1,5 @@
{
"registry-mirrors": [
"https://docker.m.daocloud.io"
]
}