Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dsandip/13e60c24c00a7c2af59d3431070f6591 to your computer and use it in GitHub Desktop.
Save dsandip/13e60c24c00a7c2af59d3431070f6591 to your computer and use it in GitHub Desktop.
Bash script to push Hasura E.E control plane images to a private registry
#!/bin/bash
json_key=$(<example.json) # JSON access key
internal_repo='localhost:8000' # URL to private container registry
docker login -u _json_key --password "$json_key" https://gcr.io # log into GCR
image_list=(`helm template lux-2.0.8.tgz | grep "image:"`) # get raw list of images from Helm charts
ignore_value="image:" # value to parse downstream
names=$(printf "'%s'\n" "${image_list[@]/$ignore_value}" | grep -v "''" | tr -d \'\" | tr -d "\r" | sort -u | uniq) # Assign output to variable via Bash command substitution
SAVEIFS=$IFS # Save current IFS (Internal Field Separator)
IFS=$'\n' # Change IFS to newline char
names=($names) # split the `names` string into an array by the same name
for lux_image in ${names[@]};
do
IFS='/'
read -a image_name <<< "$lux_image" # parse image URL into components
docker pull "$lux_image"
docker tag "$lux_image" "$internal_repo/${image_name[2]}"
docker push "$internal_repo/${image_name[2]}"
done
IFS=$SAVEIFS # Restore original IFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment