#!/usr/bin/env bash # Pushes every image ./build-image.sh built locally - the fuelish tools # image and the Android CI/release build image, each already verified # (tools image with the numbered pipeline scripts, android-builder image # with ./run-image.sh) - to a container registry, so the k3s cluster can # pull the tools image and Gitea Actions can pull the android-builder # image without rebuilding either. 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_IMAGE:?registry.env must set REGISTRY_IMAGE}" : "${REGISTRY_ANDROID_IMAGE:?registry.env must set REGISTRY_ANDROID_IMAGE}" : "${REGISTRY_USER:?registry.env must set REGISTRY_USER}" : "${REGISTRY_PASSWORD:?registry.env must set REGISTRY_PASSWORD}" TOOLS_VERSION="$(<"$ROOT/tooling-container/VERSION")" [ -n "$TOOLS_VERSION" ] || fail "tooling-container/VERSION is empty" ANDROID_VERSION="$(<"$ROOT/build-image/VERSION")" [ -n "$ANDROID_VERSION" ] || fail "build-image/VERSION is empty" docker image inspect "$REGISTRY_IMAGE:$TOOLS_VERSION" >/dev/null 2>&1 \ || fail "$REGISTRY_IMAGE:$TOOLS_VERSION not found locally - run ./build-image.sh first" docker image inspect "$REGISTRY_ANDROID_IMAGE:$ANDROID_VERSION" >/dev/null 2>&1 \ || fail "$REGISTRY_ANDROID_IMAGE:$ANDROID_VERSION not found locally - run ./build-image.sh first" echo "== Logging in to $REGISTRY ==" echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin echo "== Pushing $REGISTRY_IMAGE:$TOOLS_VERSION and :latest ==" docker push "$REGISTRY_IMAGE:$TOOLS_VERSION" docker push "$REGISTRY_IMAGE:latest" echo "== Pushing $REGISTRY_ANDROID_IMAGE:$ANDROID_VERSION and :latest ==" docker push "$REGISTRY_ANDROID_IMAGE:$ANDROID_VERSION" docker push "$REGISTRY_ANDROID_IMAGE:latest" echo "== Done ==" echo "Images: $REGISTRY_IMAGE:$TOOLS_VERSION, $REGISTRY_ANDROID_IMAGE:$ANDROID_VERSION"