fix: record the replaced images before the database step, for the whole project
CI / check (pull_request) Successful in 22s

The record was taken right before the engine's swap. Since then the database
step and the broker replace their containers earlier, so a new PostgreSQL or
Valkey image left the old one on the host for good; docker image prune -af
used to take it. It also listed only the engine services, so postgres (behind
its compose profile), apt-cacher-ng, signal-api and the retired registry were
never recorded.

deploy.sh now records the images of every container of the compose project
netork, by its label, before the database step, and keeps only image IDs:
they are expanded into the command that removes them. They are still removed
only after the verification and the migration; a failed deploy removes
nothing. remove_replaced_images.sh says nothing about an image still in use,
which most of them now are on every deploy, and names only what it removed or
could not remove.
This commit is contained in:
Christian Manivong committed 2026-12-02 17:27:03 +01:00
1 parent 31cc9da537
commit abefafe070
6 files changed
+121 -44

No files matched your search

+10 -6
View File
@@ -136,12 +136,16 @@ started earlier pulls whatever image the registry held before, which is stale.
11. Verifies that the containers run exactly the image that was pulled. If they don't, the
deploy fails.
12. Runs `alembic upgrade head` inside `netork-api`.
13. Removes the images the swap replaced, and only those. Before the swap it records which
images netOrk's own containers use; afterwards `remote/remove_replaced_images.sh`
removes them unless a container still uses one, a redeploy of the same tag for
example. Other projects' images on the host stay. This used to be
`docker image prune -af`, which took every unused image, theirs included
(NetOrk/kb-server#157).
13. Removes the images this deploy replaced, and only those. Before step 5, the first
that can replace a container, it records the images of every container of the
compose project `netork`: the engine, the database, the broker, the infrastructure
containers and any retired service. After the migration,
`remote/remove_replaced_images.sh` removes them, unless a container still uses one:
a redeploy of the same tag, or a database whose image did not change. It names only
what it removed. Other projects' images on
the host stay. A deploy that failed earlier removes nothing, so the previous images
remain for the way back. This used to be `docker image prune -af`, which took every
unused image, theirs included (NetOrk/kb-server#157).
A failing step stops that server's deploy with a non-zero exit, and the other servers
carry on. The script exits non-zero if any server failed and names those servers.