Add Docker mirror configuration and build scripts
Some checks failed
Build and Deploy / test-backend (push) Has been cancelled
Build and Deploy / build-backend (push) Has been cancelled
Build and Deploy / build-admin (push) Has been cancelled
Deploy to Production / build-backend (push) Has been cancelled
Deploy to Production / deploy (push) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
bujie9527
2026-02-05 22:42:05 +08:00
parent ed3a5c0486
commit 3c95ae0000
4 changed files with 335 additions and 2 deletions

119
DOCKER_MIRROR_CONFIG.md Normal file
View File

@@ -0,0 +1,119 @@
# Docker 镜像加速配置Windows Docker Desktop
## 快速配置步骤
### 1. 打开 Docker Desktop 设置
1. 右键点击系统托盘中的 **Docker Desktop** 图标
2. 选择 **Settings**(设置)
### 2. 配置镜像加速
1. 在左侧菜单选择 **Docker Engine**
2. 在 JSON 配置中添加 `registry-mirrors`
```json
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
```
3. 点击 **Apply & Restart**
4. 等待 Docker 重启完成(通常需要 10-30 秒)
### 3. 验证配置
重启后,在终端运行:
```powershell
docker info | Select-String -Pattern "Registry Mirrors"
```
应该能看到配置的镜像源。
### 4. 重新构建
配置完成后,重新运行构建命令:
```powershell
docker build -f deploy/docker/backend.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-backend:latest .
```
## 镜像源列表
### 推荐镜像源(按优先级)
1. **USTC 镜像**`https://docker.mirrors.ustc.edu.cn`
- 中科大镜像,速度较快
2. **网易镜像**`https://hub-mirror.c.163.com`
- 网易提供,稳定可靠
3. **百度镜像**`https://mirror.baidubce.com`
- 百度云提供
4. **阿里云镜像**(需要账号):
- 访问https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
- 获取专属加速地址
## 如果配置后仍然失败
### 方案 A使用构建参数
```powershell
# Backend
docker build --build-arg PYTHON_IMAGE=docker.mirrors.ustc.edu.cn/library/python:3.12-slim -f deploy/docker/backend.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-backend:latest .
# Admin
docker build --build-arg NODE_IMAGE=docker.mirrors.ustc.edu.cn/library/node:20-alpine -f deploy/docker/admin.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-admin:latest .
```
### 方案 B手动拉取基础镜像
```powershell
# 拉取基础镜像
docker pull docker.mirrors.ustc.edu.cn/library/python:3.12-slim
docker pull docker.mirrors.ustc.edu.cn/library/node:20-alpine
# 打标签
docker tag docker.mirrors.ustc.edu.cn/library/python:3.12-slim python:3.12-slim
docker tag docker.mirrors.ustc.edu.cn/library/node:20-alpine node:20-alpine
# 然后正常构建
docker build -f deploy/docker/backend.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-backend:latest .
```
## 验证配置是否生效
```powershell
# 查看 Docker 信息
docker info
# 查看镜像加速配置
docker info | Select-String "Registry Mirrors" -Context 0,5
```
## 完成后的操作
配置完成后,可以正常构建和推送:
```powershell
# 构建 Backend
docker build -f deploy/docker/backend.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-backend:latest .
docker push registry.667788.cool/wecom-ai/wecom-ai-backend:latest
# 构建 Admin
docker build -f deploy/docker/admin.Dockerfile -t registry.667788.cool/wecom-ai/wecom-ai-admin:latest .
docker push registry.667788.cool/wecom-ai/wecom-ai-admin:latest
```