Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22: add auth for crane commands #23

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,33 @@ if [[ "${DOCKER_AUDIT_IMAGE:-1}" == 1 ]]; then
fi


#################################################
# runs crane commands in a Docker container
# authenticates with the registry using env vars
# usage: crane_command <crane args>
#################################################
crane_command() {
docker run --rm -it \
-e DOCKER_REGISTRY="$DOCKER_REGISTRY" \
-e DOCKER_REGISTRY_USERNAME="$DOCKER_REGISTRY_USERNAME" \
-e DOCKER_REGISTRY_TOKEN="$DOCKER_REGISTRY_TOKEN" \
--entrypoint sh \
gcr.io/go-containerregistry/crane:debug -c "
crane auth login -u \$DOCKER_REGISTRY_USERNAME -p \$DOCKER_REGISTRY_TOKEN \$DOCKER_REGISTRY && crane $*"
}


#################################################
# push image with tags to remote docker image registry
#################################################
if [[ "${DOCKER_PUSH:-0}" == "1" ]]; then
docker run --network host --rm gcr.io/go-containerregistry/crane copy $local_registery/$image_name $docker_registry/$image_name
crane_command copy $local_registery/$image_name $docker_registry/$image_name

if [[ $graalvm_version != *dev* ]]; then
if [[ $java_major_version == "11" ]]; then
docker run --network host --rm gcr.io/go-containerregistry/crane copy $local_registery/$image_name $docker_registry/$image_repo:$graalvm_version-java$java_major_version # e.g. 22.3.2-java11
crane_command copy $local_registery/$image_name $docker_registry/$image_repo:$graalvm_version-java$java_major_version # e.g. 22.3.2-java11
else
docker run --network host --rm gcr.io/go-containerregistry/crane copy $local_registery/$image_name $docker_registry/$image_repo:$graalvm_version # e.g. 17.0.7
crane_command copy $local_registery/$image_name $docker_registry/$image_repo:$graalvm_version # e.g. 17.0.7
fi
fi
fi