-
Notifications
You must be signed in to change notification settings - Fork 2
/
dockerhub-build.sh
executable file
·76 lines (63 loc) · 2.44 KB
/
dockerhub-build.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
#!/usr/bin/env sh
# -----------------------------------------------------------------------------
# Docker Build Container (DockerHub)
# -----------------------------------------------------------------------------
# Author : Dwi Fahni Denni
# License : Apache v2
# -----------------------------------------------------------------------------
set -e
# export CI_PROJECT_PATH="devopscorner"
# export CI_PROJECT_NAME="k8s-context"
# export IMAGE="$CI_PROJECT_PATH/$CI_PROJECT_NAME"
export IMAGE=$2
docker_build() {
export FILE=$1
export BASE_IMAGE=$3
export TAGS_ID=$4
export CUSTOM_TAGS=$5
if [ "$CUSTOM_TAGS" = "" ]; then
echo "Build Image => $IMAGE:$BASE_IMAGE"
echo ">> docker build -t $IMAGE:$BASE_IMAGE -f $FILE ."
docker build -t $IMAGE:$BASE_IMAGE -f $FILE .
echo '---'
echo "Build Image => $IMAGE:$TAGS_ID"
echo ">> docker build -t $IMAGE:$TAGS_ID -f $FILE ."
docker build -t $IMAGE:$TAGS_ID -f $FILE .
echo '---'
echo "Build Image => $IMAGE:$BASE_IMAGE-$TAGS_ID"
echo ">> docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID -f $FILE ."
docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID -f $FILE .
echo '---'
else
echo "Build Image => $IMAGE:$BASE_IMAGE"
echo ">> docker build -t $IMAGE:$BASE_IMAGE -f $FILE ."
docker build -t $IMAGE:$BASE_IMAGE -f $FILE .
echo '---'
echo "Build Image => $IMAGE:$TAGS_ID"
echo "docker build -t $IMAGE:$TAGS_ID -f $FILE ."
docker build -t $IMAGE:$TAGS_ID -f $FILE .
echo '---'
echo "Build Image => $IMAGE:$BASE_IMAGE-$TAGS_ID"
echo ">> docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID -f $FILE ."
docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID -f $FILE .
echo '---'
echo "Build Image => $IMAGE:$TAGS_ID-$CUSTOM_TAGS"
docker build -t $IMAGE:$TAGS_ID-$CUSTOM_TAGS -f $FILE .
echo ">> docker build -t $IMAGE:$TAGS_ID-$CUSTOM_TAGS -f $FILE ."
echo '---'
echo "Build Image => $IMAGE:$BASE_IMAGE-$TAGS_ID-$CUSTOM_TAGS"
echo ">> docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID-$CUSTOM_TAGS -f $FILE ."
docker build -t $IMAGE:$BASE_IMAGE-$TAGS_ID-$CUSTOM_TAGS -f $FILE .
echo '---'
fi
}
main() {
# docker_build Dockerfile devopscorner/k8s-context alpine [version|latest|tags] [custom-tags]
docker_build $1 $2 $3 $4 $5
echo ''
echo '-- ALL DONE --'
}
### START HERE ###
main $1 $2 $3 $4 $5
### How to Execute ###
# ./dockerhub-build.sh Dockerfile [DOCKERHUB_IMAGE_PATH] [alpine] [version|latest|tags] [custom-tags]