-
Notifications
You must be signed in to change notification settings - Fork 7
/
opentrons-build-container.sh
executable file
·66 lines (54 loc) · 1.35 KB
/
opentrons-build-container.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
#!/usr/bin/env bash
# Utilities for the opentrons build container.
if [[ -n "${CI}" ]]; then
filter_arg="--build-arg filter_output=true"
fi
githubname="$(git describe --all --dirty --always | tr '[:upper:]' '[:lower:]')"
imgname=ghcr.io/opentrons/buildroot
noheads=${githubname/heads//}
imgtag=${noheads:2}
help () {
cat <<EOF
$0: Utilities for opentrons build container. Argument is a single word:
$0 build: build a container locally and return its name
$0 push: push a container. It will be the last one built.
$0 build-push: build a container then push it.
$0 pull: pull the latest container for running
EOF
exit 1
}
build () {
docker build ${filter_arg} -t ${imgname}:${imgtag} -t ${imgname}:latest . 1>&2 || exit 1
echo ${imgname}:${imgtag}
}
push () {
docker push ${imgname}:latest 1>&2 || exit 1
echo ${imgname}:latest
}
pull () {
docker pull ${imgname}:latest 1>&2 || exit 1
echo ${imgname}:latest
}
case $# in
0)
help
;;
*)
case $1 in
build)
build && exit 0
;;
push)
push && exit 0
;;
build-push)
build && push && exit 0
;;
pull)
pull && exit 0
;;
*)
help
;;
esac
esac