wealth/docs/decisions/0068-keep-the-previous-rele...

1.4 KiB

0068 Keep the previous release for rollback

Status: Accepted · Area: architecture · Date: 2026-10-16 · Decided by: user

Context

tools/deploy.sh (0067) swapped two fixed containers, <app>-blue and <app>-green, and removed the old release, so going back meant a full rebuild of an earlier commit. The user asked for a rollback beside the deploy.

Decision

  • Name each deploy's container <app>-<UTC time of the deploy>, with its env file in .deploy/<app>/<container>/.
  • After a swap, keep the old release as a stopped container with its env folder; remove every older one.
  • bash tools/rollback.sh <app> stops the serving container and starts the previous one, checked against /healthz; a failing previous release leaves the serving one in place. Running it again rolls forward.
  • Deploy and rollback of one app share .deploy/<app>/.lock.

Alternatives

  • Rebuild an earlier commit with tools/deploy.sh: still works for older releases, but takes a build, and the env may have changed since.
  • Keep more than one previous release: more disk and more env folders with secrets, for a case a checkout and deploy already covers.

Consequences

  • A rollback takes seconds and builds nothing; the previous release keeps the port it was deployed with.
  • Containers from the blue/green script (<app>-blue, <app>-green) are invisible to both scripts: remove them, and .deploy/<app>/blue and green, before the first deploy with this one.