Skip to content
Snippets Groups Projects
Verified Commit 6b330f9e authored by Alexander Wellbrock's avatar Alexander Wellbrock
Browse files

add si-pull tool

The image pull is now done in it's own script file to handle the logic
of trying different expected images and fail if none was found.
parent 5a683bc1
No related branches found
No related tags found
No related merge requests found
......@@ -58,9 +58,7 @@ container-tagging:
- podman login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- export BUILD_DATE="$(date --rfc-3339 ns)"
script:
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA || true
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-amd64" || true
- podman pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-arm64" || true
- si-pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA"
- si-tagging -l "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE" "${CI_REGISTRY_IMAGE_VERSION}"
- si-push "$CI_REGISTRY_IMAGE"
resource_group: latest
......
#!/bin/bash
set -o pipefail
set -u
set -e
VERSION=0.1.0
printVersion() {
echo "$VERSION"
}
printUsage() {
printVersion
echo "
Shivering-Isles pull tool
This tool will pull all available base container images from upstream
Usage of $0:
$0 <IMAGE REFERENCE>
Example:
$0 registry.example.com/example/app
"
exit 1
}
CONTAINER_CMD=podman
if ! command -v "$CONTAINER_CMD" >/dev/null 2>&1; then
CONTAINER_CMD=docker
fi
if [ "$1" = "--help" ]; then
printUsage
fi
for i in "$@"
do
case $i in
--container-cmd=*)
CONTAINER_CMD="${i#*=}"
shift # past argument with no value
;;
-v|--version)
printVersion
exit 0
shift # past argument with no value
;;
-h|--help)
printUsage
shift
;;
*)
# further/unknown options
;;
esac
done
CONTAINER_IMAGE_NAME=${1:-invalid}
if [ "$CONTAINER_IMAGE_NAME" = "invalid" ]; then
echo "Error: Invalid image name" >&2
printUsage
fi
IMAGE_PULL_SUCCESS=0
podman pull "$CONTAINER_IMAGE_NAME" && \
IMAGE_PULL_SUCCESS=1 || \
true
podman pull "$CONTAINER_IMAGE_NAME-amd64" && \
IMAGE_PULL_SUCCESS=1 || \
true
podman pull "$CONTAINER_IMAGE_NAME-arm64" || \
podman pull "$CONTAINER_IMAGE_NAME-aarch64" && \
IMAGE_PULL_SUCCESS=1 || \
true
if [ "$IMAGE_PULL_SUCCESS" == "0" ]; then
echo "Error: No images pulled" >&2
exit 1
fi
......@@ -4,10 +4,13 @@ BASENAME="$(dirname "$0")"
cp "$BASENAME"/./bin/tagging.sh /usr/local/bin/si-tagging
cp "$BASENAME"/./bin/push.sh /usr/local/bin/si-push
cp "$BASENAME"/./bin/pull.sh /usr/local/bin/si-pull
cp "$BASENAME"/./bin/fix-dockerfile.sh /usr/local/bin/si-fix
chown root:root /usr/local/bin/si-tagging
chown root:root /usr/local/bin/si-push
chown root:root /usr/local/bin/si-pull
chown root:root /usr/local/bin/si-fix
chmod 0755 /usr/local/bin/si-tagging
chmod 0755 /usr/local/bin/si-push
chmod 0755 /usr/local/bin/si-pull
chmod 0755 /usr/local/bin/si-fix
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment