diff --git a/skopeo-sync/Dockerfile b/skopeo-sync/Dockerfile new file mode 100644 index 0000000..c49b96f --- /dev/null +++ b/skopeo-sync/Dockerfile @@ -0,0 +1,4 @@ +FROM ustcmirror/base:alpine-edge +LABEL maintainer "Keyu Tao " +RUN apk add --no-cache skopeo +ADD sync.sh / diff --git a/skopeo-sync/sync.sh b/skopeo-sync/sync.sh new file mode 100755 index 0000000..43e39c1 --- /dev/null +++ b/skopeo-sync/sync.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +VERIFY_TLS=${VERIFY_TLS:-"false"} + +if [ ! -f /etc/skopeo-images.yaml ]; then + echo "Please bind mount skopeo config file to /etc/skopeo-images.yaml" + exit 255 +fi + +if [ -n "$NEEDS_LOGIN" ]; then + skopeo login --tls-verify="$VERIFY_TLS" "$REGISTRY_HOST" -u "$REGISTRY_USERNAME" -p "$REGISTRY_PASSWORD" + if [ $? -ne 0 ]; then + echo "Registry login failed" + exit 255 + fi +fi + +exec skopeo --insecure-policy sync --dest-tls-verify="$VERIFY_TLS" --scoped --src yaml --dest docker /etc/skopeo-images.yaml "$REGISTRY_HOST"