create: 托管应用清单 user_auth 可为 none(只有管理页)
MemRelay-Operation: memory-save:fact-hosted-app-user-auth-none-2026-11-12 MemRelay-Resource: e2ac9869-4c3f-4e30-a326-17b64322c6ff
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
---
|
||||
title: 本机 Docker 不可用时,在生产服务器上构建 Metrix 和 InterferenceETL 镜像
|
||||
type: experience
|
||||
permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/本机-docker-不可用时在生产服务器上构建-metrix-和-interference-etl-镜像
|
||||
stable_id: ebcbb471-a0be-4230-aeb7-f6ffa960d4aa
|
||||
scope: project
|
||||
memory_type: experience
|
||||
project_id: d5a7f581-c442-4554-87b9-ee723b8b0258
|
||||
usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998
|
||||
status: active
|
||||
revision: 1
|
||||
request_id: exp-build-on-prod-docker-2026-11-12
|
||||
created_at: '2026-11-12T04:06:45.020953+00:00'
|
||||
updated_at: '2026-11-12T04:06:45.020953+00:00'
|
||||
tags:
|
||||
- metrix
|
||||
- interference-etl
|
||||
- deploy
|
||||
- docker
|
||||
---
|
||||
|
||||
2026-11-12 开发机 Docker Desktop 报「unable to start」,用户要求直接用线上服务器的 Docker。服务器是内网,不能 pull 也不能 pip install,所以都在现有镜像上叠加代码。临时脚本在 Temp/prod(不提交),都通过 scripts/prod/ssh.py(支持 `run 脚本 参数…` 和 `put`)执行。服务器宿主机没有 python3,有 zip、tar、curl。
|
||||
|
||||
## Metrix
|
||||
1. 本机 `npm run build`(web/dist)。
|
||||
2. `Temp/prod/make_metrix_context.py <tar>`:`git archive HEAD server/app examples/hosted-app scripts/docker/Dockerfile.app-overlay` 加上 web/dist,约 27 MB。
|
||||
3. put 到 `/opt/metrix/releases/metrix-context-<tag>.tar`,运行 `Temp/prod/metrix-build.sh <tag> <基础tag>`:校验基础 tag 就是正在运行的镜像,`docker build --build-arg BASE_IMAGE=metrix-app:<基础tag> -f scripts/docker/Dockerfile.app-overlay`,再 `docker save` 到 `/opt/metrix/releases/metrix-app-<tag>.tar`。
|
||||
4. 运行仓库里的 `scripts/prod/release-web.sh <tag>`(不改):旁路容器健康检查、切换、失败自动回滚、校验。
|
||||
|
||||
坑:`FROM sha256:<镜像ID>` 会被 BuildKit 当成 docker.io/library/sha256 去仓库查,内网直接失败;基础镜像必须写成本地 tag。脚本里 `docker build | tail` 要配 `set -o pipefail`。
|
||||
|
||||
切换前要确认没有正在执行的托管应用任务(Temp/prod/apps_state.py 看 job 列),因为 Metrix 启动时会把 pending/running 的应用任务标成失败。各应用登记版本与运行容器一致时,重启 Metrix 不会重建应用容器。
|
||||
|
||||
`Temp/prod/current-web-tag.txt` 没有改,仍是 dbc78cd:本机 Docker 里没有 9354ea3 镜像,下次在本机跑 publish-web.ps1 仍以 dbc78cd 为基础即可(叠加层会整体覆盖 server/app 和 web/dist)。
|
||||
|
||||
## InterferenceETL
|
||||
依赖(requirements-app.txt、deploy/Dockerfile)没变时:
|
||||
1. `plugins/InterferenceETL/.venv/Scripts/python.exe Temp/prod/make_etl_context.py <tar> <上一版提交>`:校验依赖未变,打包 main.py、etl_app、叠加用 Dockerfile、由 package_metrix.manifest() 生成的 metrix-app.json 和 icon.svg,最后一行输出版本号。
|
||||
2. put 到 `/opt/metrix/releases/etl-context-<版本>.tar`,运行 `Temp/prod/etl-build.sh <版本> <上一版本>`:在上一版镜像上 COPY 代码,`docker save` 后用 zip 组成应用包 `/opt/metrix/releases/interference-etl-<版本>.zip`。
|
||||
3. `Temp/prod/sshget.py <远端> <本地>` 把包下载到 plugins/InterferenceETL/dist/metrix/,再用 `Temp/prod/deploy_etl.py <zip>` 走 Metrix 更新接口。完成后删掉服务器上的 zip。
|
||||
|
||||
依赖有变化时这个办法不适用,需要能联网构建的机器。
|
||||
Reference in New Issue
Block a user