forked from basschipper/docker-otmonitor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·41 lines (36 loc) · 1023 Bytes
/
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
#!/bin/sh
NAME=$(grep "name" build.config | cut -d '=' -f2)
VERSION=$(grep "version" build.config | cut -d '=' -f2)
IMAGE="${NAME}:${VERSION}"
IMAGE_LATEST="${NAME}:latest"
image() {
echo "Build image ${IMAGE}"
docker build \
--tag ${IMAGE} \
--force-rm \
.
}
push() {
echo "Push image ${REGISTRY}/${IMAGE}"
docker tag ${REGISTRY}/${IMAGE} ${REGISTRY}/${IMAGE_LATEST}
docker push ${REGISTRY}/${IMAGE}
docker push ${REGISTRY}/${IMAGE_LATEST}
}
help() {
echo "Usage: ./build.sh <function>"
echo ""
echo "Functions"
printf " \033[36m%-30s\033[0m %s\n" "image" "Build the Docker image."
printf " \033[36m%-30s\033[0m %s\n" "push" "Push the Docker image."
echo ""
echo "Content of build.config"
printf " \033[36m%-30s\033[0m %s\n" "name=<name>" "Name of the Docker image, required."
printf " \033[36m%-30s\033[0m %s\n" "version=<version>" "Version of the Docker image, required."
echo ""
}
if [ -z "${1}" ]; then
echo "ERROR: function required"
help
exit 1
fi
${1}