chore(deploy): publish by default and pin production images

This commit is contained in:
2026-11-23 16:50:17 +01:00
parent e46108fecc
commit a81f4ab9be
5 changed files with 26 additions and 27 deletions

View File

@ -1,15 +1,16 @@
#!/usr/bin/env bash
# Build all four images before optional publication. Authentication stays in Docker.
# Build all four images before publication. Authentication stays in Docker.
# Disable tracing even when invoked with bash -x: command output may contain secrets.
set +x
set -euo pipefail
usage() {
cat <<'HELP'
Usage: publish-images.sh [--tag TAG] [--dry-run] [--push]
Usage: publish-images.sh [--tag TAG] [--dry-run]
--tag TAG Image tag (default: full Git HEAD SHA)
--dry-run Print the plan without executing Docker
--push Publish after all four builds succeed
Builds and pushes all four images by default.
--push Accepted for compatibility; publication is already the default.
-h, --help Show this help
HELP
}
@ -18,7 +19,6 @@ fail() { printf '%s\n' "$1" >&2; exit 1; }
tag=''
tag_set=false
dry_run=false
push=false
while (($#)); do
case "$1" in
--tag)
@ -28,7 +28,7 @@ while (($#)); do
shift 2
;;
--dry-run) dry_run=true; shift ;;
--push) push=true; shift ;;
--push) shift ;;
-h|--help) usage; exit 0 ;;
*) fail 'Unknown argument; use --help' ;;
esac
@ -81,9 +81,7 @@ for name in backend frontend scraper laya; do
"${extra[@]}" "$context"
if ! "$dry_run"; then printf 'build completed: %s\n' "$image"; fi
done
if "$push"; then
for image in "${images[@]}"; do
run docker push "$image"
if ! "$dry_run"; then printf 'push completed: %s\n' "$image"; fi
done
fi
for image in "${images[@]}"; do
run docker push "$image"
if ! "$dry_run"; then printf 'push completed: %s\n' "$image"; fi
done

View File

@ -40,12 +40,14 @@ else:
return result, calls
def test_publication_contract(self):
for args, builds, pushes in [([], 4, 0), (['--push'], 4, 4),
(['--dry-run', '--push'], 0, 0)]:
for args, builds, pushes in [([], 4, 4), (['--push'], 4, 4),
(['--dry-run'], 0, 0), (['--dry-run', '--push'], 0, 0)]:
with self.subTest(args=args):
result, calls = self.invoke(args)
self.assertEqual(result.returncode, 0, result.stderr)
docker = [c for c in calls if c[0] == 'docker']
if '--dry-run' in args:
self.assertEqual(result.stdout.count('docker push '), 4)
self.assertEqual([c[1] for c in docker], ['build'] * builds + ['push'] * pushes)
for i, name in enumerate(['backend', 'frontend', 'scraper', 'laya']):
self.assertIn(PREFIX + name + ':' + SHA, result.stdout)
@ -61,7 +63,7 @@ else:
def test_failures_stop_publication(self):
for failure, count in [('build', 1), ('push', 5)]:
result, calls = self.invoke(['--push', '--tag', 'v2'], fail=failure)
result, calls = self.invoke(['--tag', 'v2'], fail=failure)
self.assertNotEqual(result.returncode, 0)
docker = [c for c in calls if c[0] == 'docker']
self.assertEqual(len(docker), count)