docs: 部署手册适配一键部署,去掉环境变量与示例配置
部署仓已改为开箱即用:config/ 直接是配置文件、口令等值内置在
docker-compose.yml、不再有 .env。
同步调整:
- 概览:部署流程改为 git clone + docker compose up -d 三步
- 配置说明:重写为「编排层 + 应用层」,说明为何不用环境变量
(GoFrame 不展开配置文件中的 ${VAR})、改口令需同步三处、
口令不能含 @ : / 等字符
- 启动与验证:去掉准备步骤,schema 脚本数改为 13 个
- 环境准备:镜像仓库改为描述编排文件中的实际地址
- 升级备份/离线/分离/自建镜像:.env 相关操作改为修改编排文件
This commit is contained in:
+69
-27
@@ -123,49 +123,91 @@ docker build --build-arg GOPROXY=https://goproxy.cn,direct -t ... .
|
||||
|
||||
## 镜像命名规则
|
||||
|
||||
部署编排按以下名称拉取镜像,自建时需保持一致:
|
||||
部署编排按以下名称拉取镜像,自建时需保持一致。`<镜像仓库>` 即官方仓库前缀 `crpi-qflrqrxoohllkvgc.cn-chengdu.personal.cr.aliyuncs.com`:
|
||||
|
||||
| 服务 | 镜像名 |
|
||||
| --- | --- |
|
||||
| admin-svr | `<REGISTRY>/iotlcm/iotlcm-admin-svr:<TAG>` |
|
||||
| admin-ui | `<REGISTRY>/iotlcm/iotlcm-admin-ui:<TAG>` |
|
||||
| openapi | `<REGISTRY>/iotlcm/iotlcm-openapi:<TAG>` |
|
||||
| app-server | `<REGISTRY>/iotlcm/iotlcm-app-server:<TAG>` |
|
||||
| app-web | `<REGISTRY>/iotlcm/iotlcm-app-web:<TAG>` |
|
||||
| upstream-chan | `<REGISTRY>/iotlcm/iotlcm-upstream-chan:<TAG>` |
|
||||
| upstream-proxy | `<REGISTRY>/iotlcm/iotlcm-upstream-proxy:<TAG>` |
|
||||
| worker-svr | `<REGISTRY>/iotlcm/iotlcm-worker-svr:<TAG>` |
|
||||
| sms | `<REGISTRY>/iotlcm/iotlcm-sms:<TAG>` |
|
||||
| bot | `<REGISTRY>/iotlcm/iotlcm-bot:<TAG>` |
|
||||
| docs | `<REGISTRY>/iotlcm/iotlcm-docs:<TAG>` |
|
||||
| onelink-mock | `<REGISTRY>/iotlcm/iotlcm-onelink-mock:<TAG>` |
|
||||
| admin-svr | `<镜像仓库>/iotlcm/iotlcm-admin-svr:<TAG>` |
|
||||
| admin-ui | `<镜像仓库>/iotlcm/iotlcm-admin-ui:<TAG>` |
|
||||
| openapi | `<镜像仓库>/iotlcm/iotlcm-openapi:<TAG>` |
|
||||
| app-server | `<镜像仓库>/iotlcm/iotlcm-app-server:<TAG>` |
|
||||
| app-web | `<镜像仓库>/iotlcm/iotlcm-app-web:<TAG>` |
|
||||
| upstream-chan | `<镜像仓库>/iotlcm/iotlcm-upstream-chan:<TAG>` |
|
||||
| upstream-proxy | `<镜像仓库>/iotlcm/iotlcm-upstream-proxy:<TAG>` |
|
||||
| worker-svr | `<镜像仓库>/iotlcm/iotlcm-worker-svr:<TAG>` |
|
||||
| sms | `<镜像仓库>/iotlcm/iotlcm-sms:<TAG>` |
|
||||
| bot | `<镜像仓库>/iotlcm/iotlcm-bot:<TAG>` |
|
||||
| docs | `<镜像仓库>/iotlcm/iotlcm-docs:<TAG>` |
|
||||
| onelink-mock | `<镜像仓库>/iotlcm/iotlcm-onelink-mock:<TAG>` |
|
||||
|
||||
基础组件(`library/mysql`、`library/redis` 等)直接使用上游官方镜像,无需自建。
|
||||
基础组件(`mysql`、`redis`、`rabbitmq`、`consul`、`nginx`)不需要构建,只需从上游同步到 `<镜像仓库>/library/`,见下节。
|
||||
|
||||
## 同步基础组件
|
||||
|
||||
平台编排不再从 Docker Hub 直连基础组件(公网不稳定,且 `8.0` 这类 tag 会随补丁升级而漂)。部署前先把五个镜像同步到官方仓库:
|
||||
|
||||
```bash
|
||||
REPO=crpi-qflrqrxoohllkvgc.cn-chengdu.personal.cr.aliyuncs.com
|
||||
|
||||
docker login --username=sdqmx $REPO
|
||||
|
||||
# 按 docker-compose.yml 中固定的版本拉取并推送
|
||||
sync_image() {
|
||||
local src=$1 dst=$2
|
||||
docker pull "$src"
|
||||
docker tag "$src" "$REPO/library/$dst"
|
||||
docker push "$REPO/library/$dst"
|
||||
}
|
||||
|
||||
sync_image mysql:8.0 mysql:8.0
|
||||
sync_image redis:7.2 redis:7.2
|
||||
sync_image rabbitmq:4.3.5-management rabbitmq:4.3.5-management
|
||||
sync_image hashicorp/consul:1.22 consul:1.22
|
||||
sync_image nginx:1.30 nginx:1.30
|
||||
```
|
||||
|
||||
::: warning 同步时把版本号固定到补丁位
|
||||
`mysql:8.0` 这类浮动 tag 会随上游发新补丁而变化。建议同步时锁定到具体补丁版(如 `mysql:8.0.43`),并把 `docker-compose.yml` 的 `MYSQL_VERSION` 同步改为 `8.0.43`,保证多台机器拉到的镜像完全一致。
|
||||
:::
|
||||
|
||||
同步完成后校验:
|
||||
|
||||
```bash
|
||||
for img in mysql:8.0 redis:7.2 rabbitmq:4.3.5-management consul:1.22 nginx:1.30; do
|
||||
docker manifest inspect "$REPO/library/$img" >/dev/null 2>&1 \
|
||||
&& echo "✅ $img" || echo "❌ $img"
|
||||
done
|
||||
```
|
||||
|
||||
## 推送到自己的仓库
|
||||
|
||||
```bash
|
||||
REGISTRY=harbor.internal.example.com
|
||||
TAG=1.0.3
|
||||
|
||||
docker tag iotlcm-openapi:local $REGISTRY/iotlcm/iotlcm-openapi:$TAG
|
||||
docker push $REGISTRY/iotlcm/iotlcm-openapi:$TAG
|
||||
```
|
||||
|
||||
部署时 `.env` 改为:
|
||||
自建镜像不需要推送回官方仓库。推到自有仓库后,把 `docker-compose.yml` 里的镜像前缀改指向它:
|
||||
|
||||
```bash
|
||||
REGISTRY=harbor.internal.example.com
|
||||
REG=harbor.internal.example.com
|
||||
TAG=1.0.3
|
||||
|
||||
docker tag iotlcm-openapi:local $REG/iotlcm/iotlcm-openapi:$TAG
|
||||
docker login $REG
|
||||
docker push $REG/iotlcm/iotlcm-openapi:$TAG
|
||||
```
|
||||
|
||||
```yaml
|
||||
# docker-compose.yml —— 逐个替换 image 前缀
|
||||
image: 'harbor.internal.example.com/iotlcm/iotlcm-openapi:1.0.3'
|
||||
```
|
||||
|
||||
::: tip 只覆盖部分服务
|
||||
只想替换其中一两个服务时,把对应镜像推到自有仓库,其余保留官方地址。此时把 `docker-compose.yml` 里那几个 `image` 单独写成完整地址,其余保持官方仓库前缀即可。
|
||||
:::
|
||||
|
||||
## 批量构建脚本
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
REGISTRY=${REGISTRY:?请设置 REGISTRY}
|
||||
REPO=${REPO:?请设置 REPO}
|
||||
TAG=${TAG:-$(date +%Y%m%d)}
|
||||
WORKDIR=${WORKDIR:-./repos}
|
||||
|
||||
@@ -201,12 +243,12 @@ for item in "${SERVICES[@]}"; do
|
||||
--build-arg BuildVersion="$VERSION" \
|
||||
--build-arg CommitID="$COMMIT" \
|
||||
--build-arg BuildTime="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" \
|
||||
-t "$REGISTRY/iotlcm/$image:$TAG" \
|
||||
-t "$REPO/iotlcm/$image:$TAG" \
|
||||
-f "$WORKDIR/$repo/${ctx}Dockerfile" \
|
||||
"$WORKDIR/$repo/$ctx"
|
||||
done
|
||||
|
||||
echo "全部完成,镜像标签:$REGISTRY/iotlcm/*:$TAG"
|
||||
echo "全部完成,镜像标签:$REPO/iotlcm/*:$TAG"
|
||||
```
|
||||
|
||||
::: warning 脚本里的 sed 只能应急
|
||||
|
||||
Reference in New Issue
Block a user