summaryrefslogtreecommitdiff
path: root/x/download
blob: 9f8835c9200be67db59d4c81dce0147240b0ab00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh -eu

docker image ls | grep "$1" >/dev/null && {
    echo "Image $1 already downloaded."
    exit 0
}

# string manipulation mess, basically the equivalent of "localhost:5000/(.*):\d"
registry_tag="localhost:5000/$1:dist"
_nopfx="${registry_tag##localhost:5000/}"
tag="${_nopfx%:dist}"

docker pull "$registry_tag"

echo "Renaming $registry_tag to $tag"
docker tag "$registry_tag" "$tag"
docker rmi "$registry_tag"