Files
devops-base-images-gcp/mirror.sh
T

27 lines
919 B
Bash
Executable File

#!/bin/sh
# Reads images.txt and pulls/retags/pushes each entry into Harbor's
# base-images project. Meant to run inside a docker-capable container
# with push credentials already available (docker-cli + dind sidecar,
# harbor-robot-dockerconfig mounted at /root/.docker/config.json) — same
# pattern devops-lib's build-tools.Dockerfile bootstrap already uses, see
# README.md's one-off kubectl pod commands. Not run through any Jenkins
# pipeline — genuinely one-time/occasional, re-run by hand when
# images.txt changes.
set -eu
REGISTRY="${REGISTRY:-harbor.192.168.1.7.nip.io}"
PROJECT="${PROJECT:-base-images}"
while read -r src target; do
[ -z "$src" ] && continue
case "$src" in \#*) continue ;; esac
dest="${REGISTRY}/${PROJECT}/${target}"
echo "=== ${src} -> ${dest} ==="
docker pull "$src"
docker tag "$src" "$dest"
docker push "$dest"
done < images.txt
echo "=== done ==="