-
Notifications
You must be signed in to change notification settings - Fork 8
/
buildDocker.sh
executable file
·53 lines (48 loc) · 1.42 KB
/
buildDocker.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
#!/bin/bash
DASH="============================================================================================================================"
echo " "
echo $DASH
echo " Build and Push image to repository"
# check if image name is provided
if [ -z "$1" ]; then
echo " "
echo "ERROR: image name is required "
echo " "
echo " Usage: build_push [image name] [tag] [repository/namespace] "
echo " "
echo " Parameters:"
echo " --- NAME --- -REQ/OPT- --------- DESCRIPTION --------- -- DEFAULT VALUE --"
echo " [image name] Required Name of the image to be created N/A"
echo " [tag] Optional Tag to label the image latest"
echo " [repository] Optional Target image repository docker.io/k8svisual"
echo " "
echo $DASH
echo " "
exit 1
else
IMG=$1
echo " Using provided image name : $IMG"
fi
# check if tag is provided
if [ -z "$2" ]; then
TAG="latest"
echo " Using default tag : $TAG"
else
TAG=$2
echo " Using provided tag : $TAG"
fi
# TR = target repository
if [ -z "$3" ]; then
TR="docker.io/k8svisual"
echo " Using default image repository : $TR"
else
TR=$3
echo " Using provided image repository: $TR"
fi
echo $DASH
echo " "
docker build -t ${TR}/${IMG}:${TAG} .
docker push ${TR}/${IMG}:${TAG}
echo " "
echo $DASH
echo " "