forked from GoogleContainerTools/base-images-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·89 lines (81 loc) · 2.09 KB
/
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
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
usage() {
echo "Usage: $0 [-r repository] [-v version] [-c config] [-o os]"
echo
echo "[repository]: remote repository to push the debian image to (e.g. 'gcr.io/gcp-runtimes/debian')"
echo "[version]: version of debian to build (e.g. 'stretch')"
echo "[config]: the yaml file defining the steps of the build, defaults to cloudbuild.yaml"
echo "[os]: which image to build, either debian or ubuntu. defaults to debian."
echo
exit 1
}
set -e
if [ -z "$TAG" ]
then
TAG=$(date +%Y-%m-%d-%H%M%S)
export TAG
fi
while test $# -gt 0; do
case "$1" in
--repo|--repository|-r)
shift
if test $# -gt 0; then
REPO=$1
else
usage
fi
shift
;;
--version|-v)
shift
if test $# -gt 0; then
export VERSION=$1
else
usage
fi
shift
;;
--config|-c)
shift
if test $# -gt 0; then
CONFIG=$1
else
usage
fi
shift
;;
--os|-o)
shift
if test $# -gt 0; then
OS=$1
else
usage
fi
shift
;;
*)
usage
shift
;;
esac
done
if [ -z "$OS" ]; then
OS=debian
fi
if [ -z "$CONFIG" ]; then
CONFIG=$OS/reproducible/cloudbuild.yaml
fi
if [ -z "$REPO" ] || [ -z "$VERSION" ]; then
usage
fi
if [ "$VERSION" == "stretch" ]
then
export VERSION_NUMBER=9
elif [ "$VERSION" == "buster" ]
then
export VERSION_NUMBER=10
else
echo "Invalid version $VERSION"
usage
fi
gcloud builds submit . --config="$CONFIG" --verbosity=info --substitutions=_REPO="$REPO",_TAG="$TAG",_VERSION_NUMBER="$VERSION_NUMBER"