-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·56 lines (46 loc) · 1.01 KB
/
build.sh
File metadata and controls
executable file
·56 lines (46 loc) · 1.01 KB
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
#!/bin/bash -e
export ARCHITECTURE="$1"
export OS="$2"
export HUB_ORG="$3"
export IMAGE_NAME="$4"
export TAG="master"
export HUB_IMAGE="$HUB_ORG/$IMAGE_NAME:$TAG"
check_input() {
if [ -z "$ARCHITECTURE" ]; then
echo "Missing input parameter ARCHITECTURE"
exit 1
fi
if [ -z "$OS" ]; then
echo "Missing input parameter OS"
exit 1
fi
if [ -z "$HUB_ORG" ]; then
echo "Missing input parameter HUB_ORG"
exit 1
fi
if [ -z "$IMAGE_NAME" ]; then
echo "Missing input parameter IMAGE_NAME"
exit 1
fi
}
set_build_context() {
# sed -i syntax is different on macOS
if [ "$OS" == "macOS_10.12" ]; then
sed -i "" "s/{{%TAG%}}/$TAG/g" ./image/$ARCHITECTURE/$OS/Dockerfile
else
sed -i "s/{{%TAG%}}/$TAG/g" ./image/$ARCHITECTURE/$OS/Dockerfile
fi
}
build_and_tag_image() {
docker build -f ./image/$ARCHITECTURE/$OS/Dockerfile -t "$HUB_IMAGE" .
}
push_images() {
docker push "$HUB_IMAGE"
}
main() {
check_input
set_build_context
build_and_tag_image
push_images
}
main