#!/usr/bin/env bash # Pushes the hacked build-image - already built locally with # ./hacked-build-image.sh, and ideally verified with # ./hacked-build-run-image.sh - to a container registry, so CI or other # machines can reuse it without rebuilding the whole toolchain. set -euo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" ROOT="$(pwd)" fail() { echo "PREFLIGHT FAIL: $*" >&2; exit 1; } command -v docker >/dev/null 2>&1 \ || fail "docker not found in PATH" [ -f "$ROOT/../registry.env" ] \ || fail "../registry.env not found - copy ../registry.env.example to ../registry.env and fill in your registry credentials" # shellcheck disable=SC1091 source "$ROOT/../registry.env" : "${REGISTRY:?registry.env must set REGISTRY}" : "${REGISTRY_USER:?registry.env must set REGISTRY_USER}" : "${REGISTRY_PASSWORD:?registry.env must set REGISTRY_PASSWORD}" HACKED_REGISTRY_IMAGE="${HACKED_REGISTRY_IMAGE:-questshock/hacked-builder}" VERSION="$(<"$ROOT/hacked-build-image/VERSION")" [ -n "$VERSION" ] || fail "hacked-build-image/VERSION is empty" docker image inspect "$HACKED_REGISTRY_IMAGE:$VERSION" >/dev/null 2>&1 \ || fail "$HACKED_REGISTRY_IMAGE:$VERSION not found locally - run ./hacked-build-image.sh first" echo "== Logging in to $REGISTRY ==" echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin echo "== Pushing $HACKED_REGISTRY_IMAGE:$VERSION and :latest ==" docker push "$HACKED_REGISTRY_IMAGE:$VERSION" docker push "$HACKED_REGISTRY_IMAGE:latest" echo "== Done ==" echo "Image: $HACKED_REGISTRY_IMAGE:$VERSION"