forked from getredash/redash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish_docker_images.sh
executable file
·83 lines (62 loc) · 1.54 KB
/
publish_docker_images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
function print_help() {
echo """
usage: $0 [--tag <tag>] [--build-only]
Builds and (optionally) tags and pushes docker images to METRs private registry.
Optional arguments:
-t --tag The tag to be used for the final docker
image in the repository.
--build-only Only builds the images, without tagging and
pushing to the registry.
--no-cache Do not use cache when building the image.
"""
}
BUILD_ONLY="False"
DOCKER_CACHE_FLAG=""
while [ -n "$1" ]
do
case $1 in
-t|--tag)
shift
TAG="$1"
shift;
;;
--build-only)
BUILD_ONLY="True"
shift
;;
--no-cache)
DOCKER_CACHE_FLAG="--no-cache"
shift
;;
*)
print_help
exit 0
;;
esac
done
if [ -z $TAG ] && [ $BUILD_ONLY != "True" ]
then
current_branch=$(git rev-parse --abbrev-ref HEAD )
if [ $current_branch = "metr-main" ]
then
TAG=$(git describe --tags metr-main)
else
echo "You need to provide a tag in order to push the image to registry."
echo "If you only want to build the image, use --build-only."
exit 1
fi
fi
set -e
docker build $DOCKER_CACHE_FLAG -t redash-metr .
docker build $DOCKER_CACHE_FLAG --platform linux/amd64 -t redash-metr .
function tag_and_push_image() {
NAME="$1"
docker tag ${NAME} swr.eu-de.otc.t-systems.com/metr/${NAME}:${TAG}
docker push --platform linux/amd64 swr.eu-de.otc.t-systems.com/metr/${NAME}:${TAG}
}
if [ $BUILD_ONLY != "True" ]
then
echo "Tagging images with $TAG and pushing to registry"
tag_and_push_image redash-metr
fi