deploy: limpeza pós-deploy do build cache e tags locais antigas (INF3/F2) #101
2 changed files with 27 additions and 4 deletions
|
|
@ -65,9 +65,10 @@ Settings → Actions.
|
||||||
|
|
||||||
## Rollback
|
## Rollback
|
||||||
|
|
||||||
A imagem anterior continua local e no registry (`localhost:5000/teqo-1313:<sha>`
|
A imagem anterior **não** fica mais local após a limpeza pós-deploy (INF3/F2:
|
||||||
— o registry nunca deleta). O compose anterior fica em
|
`docker builder prune` + remoção das tags locais antigas, exceto o SHA em uso)
|
||||||
`~/stack/docker-compose.yml.pre-<sha-do-deploy-que-falhou>`.
|
— o registry `localhost:5000` **nunca deleta** e é a fonte do rollback. O
|
||||||
|
compose anterior fica em `~/stack/docker-compose.yml.pre-<sha-do-deploy-que-falhou>`.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ssh homeserver
|
ssh homeserver
|
||||||
|
|
@ -76,7 +77,7 @@ cd ~/stack
|
||||||
# o backup do deploy que falhou é o compose com os tags antigos
|
# o backup do deploy que falhou é o compose com os tags antigos
|
||||||
ls docker-compose.yml.pre-* # escolha o anterior ao deploy ruim
|
ls docker-compose.yml.pre-* # escolha o anterior ao deploy ruim
|
||||||
cp docker-compose.yml.pre-<sha-anterior> docker-compose.yml
|
cp docker-compose.yml.pre-<sha-anterior> docker-compose.yml
|
||||||
# 2. a imagem antiga ainda está local; se não, puxe do registry:
|
# 2. puxar do registry (a imagem antiga já não fica local após a limpeza):
|
||||||
docker pull localhost:5000/teqo-1313:<sha-anterior>
|
docker pull localhost:5000/teqo-1313:<sha-anterior>
|
||||||
docker tag localhost:5000/teqo-1313:<sha-anterior> teqo-1313:<sha-anterior>
|
docker tag localhost:5000/teqo-1313:<sha-anterior> teqo-1313:<sha-anterior>
|
||||||
# 3. subir:
|
# 3. subir:
|
||||||
|
|
|
||||||
|
|
@ -217,4 +217,26 @@ curl -fsS -o /dev/null -X POST "$base/campanha/webauthn/login-options" \
|
||||||
body="$(curl -fsS -X POST "$base/api/revalidate" -H "x-revalidate-secret: $REVALIDATE_SECRET" || true)"
|
body="$(curl -fsS -X POST "$base/api/revalidate" -H "x-revalidate-secret: $REVALIDATE_SECRET" || true)"
|
||||||
echo "$body" | grep -q '"revalidated":true' || smoke_fail "POST /api/revalidate did not confirm"
|
echo "$body" | grep -q '"revalidated":true' || smoke_fail "POST /api/revalidate did not confirm"
|
||||||
|
|
||||||
|
# --- post-deploy cleanup (INF3/F2) --------------------------------------
|
||||||
|
# O deploy compila no homeserver e acumulava build cache + tags locais
|
||||||
|
# antigas no disco raiz (incidente 19/08: 45G de cache + ~20 tags teqo
|
||||||
|
# antigas). Best-effort e APÓS o smoke: falha de limpeza nunca falha um
|
||||||
|
# deploy verde. O registry localhost:5000 preserva as imagens (rollback
|
||||||
|
# intacto — runbook teqo-1313-deploy.md); removemos só as tags LOCAIS.
|
||||||
|
# Fail-closed: sem revision no container, não remove nada além do cache.
|
||||||
|
|
||||||
|
say "post-deploy cleanup: build cache + tags locais antigas"
|
||||||
|
docker builder prune -f >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
in_use="$(docker inspect -f '{{index .Config.Labels "org.opencontainers.image.revision"}}' teqo-1313 2>/dev/null || true)"
|
||||||
|
if [ -n "$in_use" ]; then
|
||||||
|
for img in $(docker images --format '{{.Repository}}:{{.Tag}}' | grep -E '^(localhost:5000/)?teqo-1313(-migrator)?:' || true); do
|
||||||
|
tag="${img##*:}"
|
||||||
|
[ "$tag" = "$in_use" ] && continue
|
||||||
|
docker rmi "$img" >/dev/null 2>&1 || true
|
||||||
|
done
|
||||||
|
else
|
||||||
|
say "cleanup: container sem revision — mantendo imagens locais"
|
||||||
|
fi
|
||||||
|
|
||||||
say "deploy of $SHA complete: $(docker inspect -f '{{.Image}}' teqo-1313)"
|
say "deploy of $SHA complete: $(docker inspect -f '{{.Image}}' teqo-1313)"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue