-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-helper.sh
executable file
·75 lines (62 loc) · 1.61 KB
/
docker-helper.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
#!/bin/sh
ORG_NAME=kajdreef
IMAGE=morpheus-backend
PLATFORMS=linux/amd64,linux/arm64
DOCKER_IMG="$ORG_NAME/$IMAGE"
docker_build() {
echo "Build docker image: $DOCKER_IMG"
VERSION=local
echo docker build . -t "$DOCKER_IMG:$VERSION"
docker build . -t "$DOCKER_IMG:$VERSION"
}
docker_buildx() {
echo "Build docker image: $DOCKER_IMG"
if [ "$1" -eq 1 ];
then
VERSION=latest
echo docker buildx build --platform $PLATFORMS -t "$DOCKER_IMG:$VERSION" . --push
docker buildx build --platform $PLATFORMS -t "$DOCKER_IMG:$VERSION" . --push
else
VERSION=unstable
echo docker buildx build --platform $PLATFORMS -t "$DOCKER_IMG:$VERSION" . --push
docker buildx build --platform $PLATFORMS -t "$DOCKER_IMG:$VERSION" . --push
fi
}
docker_run() {
VERSION=local
# Delete the unstable local and pull latest unstable image.
docker rmi "$DOCKER_IMG"
echo Run docker image: "$DOCKER_IMG:$VERSION"
echo docker run "$DOCKER_IMG:$VERSION" /bin/sh
docker run -p 5000:5000 -it "$DOCKER_IMG:$VERSION" /bin/sh
}
docker_lint() {
docker run --rm -i hadolint/hadolint < Dockerfile
}
while getopts "rbxpl" flag; do
case "$flag" in
r)
docker_run
exit 0
;;
b)
docker_build
exit 0
;;
x)
docker_buildx 0
exit 0
;;
p)
docker_buildx 1
exit 0
;;
l)
docker_lint
exit 0
;;
*)
exit 1
;;
esac
done