47 lines
1023 B
Plaintext
47 lines
1023 B
Plaintext
|
#!/bin/bash
|
||
|
DIR=$(cd "$(dirname "$BASH_SOURCE")" >/dev/null 2>&1 ; pwd -P )
|
||
|
|
||
|
#tags an image and pushes it to a <custom private> repository
|
||
|
# if not reposity is given will use docker.io and push to hub.docker.com
|
||
|
# $1 name, $2 user(or repo), $3 repo
|
||
|
|
||
|
[[ $# -lt 1 ]] && echo "image base name required" && exit
|
||
|
|
||
|
declare OPTION; declare OPTARG; declare OPTIND
|
||
|
while getopts 'daht:r:u:' OPTION; do
|
||
|
# echo processing: option:$OPTION argument:$OPTARG index:$OPTIND remaining:${@:$OPTIND}
|
||
|
case "$OPTION" in
|
||
|
d)
|
||
|
delete=true
|
||
|
;;
|
||
|
r)
|
||
|
REPO=$OPTARG
|
||
|
;;
|
||
|
u)
|
||
|
RUSER=$OPTARG
|
||
|
;;
|
||
|
t)
|
||
|
TAG=$OPTARG
|
||
|
;;
|
||
|
a) # add -arm64 to image
|
||
|
arm=arm64
|
||
|
;;
|
||
|
*) echo unknown run option -$OPTARG
|
||
|
echo "USAGE: tag <options>"
|
||
|
echo "available options: -a add -arm64 to tag, -d delete tag "
|
||
|
;;
|
||
|
esac
|
||
|
done
|
||
|
|
||
|
shift $((OPTIND - 1))
|
||
|
|
||
|
# image tag
|
||
|
name=$1
|
||
|
user=${2:-$RUSER}
|
||
|
repo=${3:-$REPO}
|
||
|
|
||
|
tag=$([[ $repo ]] && echo ${repo}/)$([[ $user ]] && echo ${user}/)$name$([[ $arm ]] && echo -arm64):${TAG:-latest}
|
||
|
|
||
|
echo $tag
|
||
|
|