-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker
executable file
·87 lines (67 loc) · 1.7 KB
/
docker
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
84
85
86
87
#!/bin/bash
set -euo pipefail
source scripts/common
help() {
echo
echo "Usage: ./scripts/docker <command>"
echo ""
echo "Commands:"
echo
echo " - cleanup"
echo " - list-images"
echo " - remove-images"
echo
echo " - base-version"
echo " - build-base-image"
echo " - build-dev-image"
echo " - build-all"
echo
}
list-images() {
echo "[INFO] Listing docker images" \
&& docker images "ext/sentinel*/*"
}
cleanup() {
echo "[INFO] Removing exited containers"
EXITED_CONTAINERS=`docker ps -a -f status=exited -q`
if [ ! -z "${EXITED_CONTAINERS}" ]
then
docker container rm ${EXITED_CONTAINERS}
else
echo "[WARNING] No containers for cleanup"
fi
echo "[INFO] Removing dangling images"
DANGLING_IMAGES=`docker images -f 'dangling=true' -q`
if [ ! -z "${DANGLING_IMAGES}" ]
then
docker image rm ${DANGLING_IMAGES}
else
echo "[WARNING] No images for cleanup"
fi
}
remove-images() {
echo "[INFO] Removing ext/sentinel images from local" \
&& docker images "ext/sentinel*/*" --quiet | xargs docker image rm \
&& docker images "ext/sentinel*" --quiet | xargs docker image rm
}
base-version() {
echo ${SENTINEL_DOCKER_VERSION}
}
build-base-image() {
echo "[INFO] Building base image" \
&& docker build \
-t ext/sentinel/base:${SENTINEL_DOCKER_VERSION} \
-f docker/Dockerfile.base docker/ \
&& echo "[INFO] Completed successfully"
}
build-dev-image() {
echo "[INFO] Building dev image" \
&& docker build \
-t ext/sentinel/dev:${SENTINEL_DOCKER_VERSION} \
-f docker/Dockerfile.dev .
}
build-all-images() {
build-base-image \
&& build-dev-image
}
$@