fix: record the version in .env before starting the containers
CI / check (pull_request) Successful in 19s
CI / check (pull_request) Successful in 19s
The services read ~/netork/.env through env_file, so whatever it says when `up -d` creates a container ends up in that container's environment. The settings were recorded only after the swap, so every container carried the previous deploy's NETORK_VERSION: the image was right, `docker exec <api> env` was not. Record them once the pull has brought the images onto the host and before the first `up -d`. A failed pull still leaves .env alone. If the swap fails afterwards, .env names the tag whose compose files and images are already on the host, which is what a hand-typed `docker compose up -d` there should start. Also say which branches a feature-<branch> tag comes from: feature/<name> and feat/<name> become feature-<name>, and fix/<name> now becomes feature-fix-<name> (NetOrk/netork#208), because the registry keeps only feature-* branch tags. The accepted forms do not change; the comment, the refusal message and the README now say so, and a test holds that feature-fix-<name> passes and a bare fix-<name> does not. Closes #6
This commit is contained in:
1 parent
a7e3617291
commit
3a15c311a0
5 files changed
+269
-57
No files matched your search
@@ -67,7 +67,9 @@ Only tags netOrk's CI publishes are accepted:
|
||||
- `latest`
|
||||
- `latest-dev`
|
||||
- `main-<sha>`
|
||||
- `feature-<branch>`
|
||||
- `feature-<name>`, a branch build: `feature/<name>` and `feat/<name>` become
|
||||
`feature-<name>`, and `fix/<name>` becomes `feature-fix-<name>`. Any further `/` in
|
||||
the branch name becomes `-` as well.
|
||||
- `X.Y.Z`
|
||||
|
||||
Anything else is refused before any server is touched.
|
||||
@@ -90,22 +92,25 @@ started earlier pulls whatever image the registry held before, which is stale.
|
||||
If the registry's answer can't be read, the pull below decides.
|
||||
2. Pulls the engine image and copies `docker-compose.yml` and
|
||||
`docker-compose.registry.yml` out of it into `~/netork/`.
|
||||
3. Pulls the netOrk images, then force-recreates the API, the workers, `netork-beat`,
|
||||
`flower` and, on UI servers, `netork-ui`. If the recreate fails, it is tried once
|
||||
more after 5 s (`DEPLOY_RECREATE_RETRY_DELAY`). Compose's parallel recreate can lose
|
||||
a container it just renamed and leave the rest stopped. If the second attempt fails
|
||||
too, the container states are printed and the deploy fails.
|
||||
4. Reconciles `apt-cacher-ng` and `signal-api`: each is recreated only if its
|
||||
3. Pulls the netOrk images.
|
||||
4. Records `REGISTRY_HOST` and `NETORK_VERSION` in `~/netork/.env`, so that a
|
||||
hand-typed `docker compose` on the host uses the same images. It does this before
|
||||
any container starts, because the services read `.env` into their environment.
|
||||
A failed pull leaves `.env` as it was.
|
||||
5. Force-recreates the API, the workers, `netork-beat`, `flower` and, on UI servers,
|
||||
`netork-ui`. If the recreate fails, it is tried once more after 5 s
|
||||
(`DEPLOY_RECREATE_RETRY_DELAY`). Compose's parallel recreate can lose a container it
|
||||
just renamed and leave the rest stopped. If the second attempt fails too, the
|
||||
container states are printed and the deploy fails.
|
||||
6. Reconciles `apt-cacher-ng` and `signal-api`: each is recreated only if its
|
||||
definition changed. It never touches `postgres` or `redis`.
|
||||
It then removes services netOrk no longer ships, container and volume, where a host
|
||||
still has them: today the bundled `registry` (NetOrk/netork#763). It reports only
|
||||
what it actually removed; on a host that was cleaned earlier it says nothing.
|
||||
5. Verifies that the containers run exactly the image that was pulled. If they don't, the
|
||||
7. Verifies that the containers run exactly the image that was pulled. If they don't, the
|
||||
deploy fails.
|
||||
6. Records `REGISTRY_HOST` and `NETORK_VERSION` in `~/netork/.env`, so that a
|
||||
hand-typed `docker compose` on the host uses the same images.
|
||||
7. Runs `alembic upgrade head` inside `netork-api`.
|
||||
8. Prunes unused images.
|
||||
8. Runs `alembic upgrade head` inside `netork-api`.
|
||||
9. Prunes unused images.
|
||||
|
||||
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.
|
||||
|
||||
Reference in new issue
Block a user