2026-05-28 23:27:15 +08:00

87 lines
3.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Docker 基础镜像仓库
本目录用于存储项目所需的基础 Docker 镜像,主要作为离线/受限网络下的备用资源。
**注意**:这不是客户正式部署入口。当前主要只有 `scripts/build-material-image.ps1` 这类内部构建脚本会优先尝试本地基础镜像;主发布脚本 `deploy-registry.ps1` 不依赖这份目录作为标准交付前提。
## 目录结构
```
docker-images/
├── README.md # 本文件
├── node/ # Node.js 基础镜像
│ └── node-18-alpine.tar # 镜像文件
├── minio-mc/ # MinIO Client 镜像
│ ├── minio-mc-latest.tar # 历史本地缓存,不可作为正式离线交付版本
│ └── VERSION.txt # 版本信息
```
当前目录下没有 `postgres/` 和 `minio/` 镜像包。`minio-mc/` 下现存的是 `minio/mc:latest` 历史缓存,只能用于本机排查,不能作为正式离线包事实。客户离线或受控网络交付时,应重新导出固定版本镜像,并在 `.env` 中显式填写 `POSTGRES_IMAGE`、`MINIO_IMAGE`、`MINIO_MC_IMAGE` 到当前可用的私有 Registry 版本镜像。
## 使用方法
### 1. 加载镜像到本地 Docker
```powershell
# Windows PowerShell
docker load -i docker-images\minio-mc\<固定版本镜像文件>.tar
# Linux/Mac
docker load -i docker-images/minio-mc/<固定版本镜像文件>.tar
```
### 2. 在内部构建脚本中使用
内部构建脚本会先检查本地镜像;如果存在则优先使用,否则再按脚本逻辑去 Registry 或网络拉取。客户正式交付不要依赖这份目录“自动生效”。
### 3. 更新镜像
当需要更新镜像时:
```powershell
# 1. 拉取固定版本镜像
docker pull minio/mc:RELEASE.2025-04-16T18-13-26Z
# 2. 保存到项目目录
docker save minio/mc:RELEASE.2025-04-16T18-13-26Z -o docker-images\minio-mc\minio-mc-RELEASE.2025-04-16T18-13-26Z.tar
# 3. 更新版本信息
echo "RELEASE.2025-04-16T18-13-26Z - $(Get-Date -Format 'yyyy-MM-dd')" > docker-images\minio-mc\VERSION.txt
```
## 镜像列表
| 镜像名称 | 版本 | 文件路径 | 大小 | 更新时间 | 用途 |
|---------|------|---------|------|---------|------|
| node | 18-alpine | `node/node-18-alpine.tar` | ~42.86 MiB | 未记录 | 素材系统构建基础镜像 |
| minio/mc | latest(历史缓存,不可交付) | `minio-mc/minio-mc-latest.tar` | ~85 MiB | 见 `minio-mc/VERSION.txt` | MinIO 客户端本机缓存 |
## 重要约定
### 构建优先使用本地基础镜像
**内部构建脚本**应优先使用本地基础镜像,避免因网络问题导致构建失败。
构建脚本会按以下顺序查找基础镜像:
1. 检查 Docker 本地是否已有该镜像
2. 如果没有,从 `docker-images/` 目录加载
3. 如果本地文件也不存在,才尝试在线拉取
这个约定主要体现在以下脚本里:
- `scripts/build-material-image.ps1` - 素材系统镜像构建
## 注意事项
1. **版本管理**:新增或更新镜像时建议同步维护 `VERSION.txt`;当前 `node/` 目录没有版本文件,不能把“每个目录都有”当成事实
2. **文件大小**:镜像文件较大,建议使用 `.gitignore` 排除,或使用 Git LFS
3. **定期更新**:定期检查并更新基础镜像,确保安全性和兼容性
4. **备份**:重要镜像建议备份到其他位置
## 添加新镜像
1. 创建镜像目录:`mkdir docker-images/<镜像名>`
2. 拉取并保存镜像:`docker pull <镜像>:<标签> && docker save <镜像>:<标签> -o docker-images/<镜像名>/<文件名>.tar`
3. 创建版本文件:`echo "<版本> - $(Get-Date -Format 'yyyy-MM-dd')" > docker-images/<镜像名>/VERSION.txt`
4. 更新本 README 的镜像列表