-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathbuild.sh
38 lines (33 loc) · 1.3 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
#!/bin/bash -e
if test -z "${DIR}"; then
echo "This script should not be called directly."
exit -1
fi
PLATFORM="${1:-Xeon}"
FRAMEWORK="${6:-gst}"
REGISTRY="$8"
RELEASE="${9:-:latest}"
build_docker() {
docker_file="$1"
shift
image_name="$1"
shift
if test -f "$docker_file.m4"; then
m4 -I "$(dirname $docker_file)" "$docker_file.m4" > "$docker_file"
fi
(cd "$DIR"; docker build --network host --file="$docker_file" "$@" -t "$image_name" -t "$image_name$RELEASE" "$DIR" $(env | cut -f1 -d= | grep -E '_(proxy|REPO|VER)$' | sed 's/^/--build-arg /') --build-arg UID=$(id -u) --build-arg GID=$(id -g))
# if REGISTRY is specified, push image to the private registry
if [ -n "$REGISTRY" ]; then
docker tag "$image_name$RELEASE" "$REGISTRY$image_name$RELEASE"
docker push "$REGISTRY$image_name$RELEASE"
fi
}
# build image(s) in order (to satisfy dependencies)
for dep in '.5.*' '.4.*' '.3.*' '.2.*' '.1.*' '.0.*' ''; do
dirs=("$DIR/$PLATFORM/$FRAMEWORK" "$DIR/$PLATFORM" "$DIR")
for dockerfile in $(find "${dirs[@]}" -maxdepth 1 -name "Dockerfile$dep" -print 2>/dev/null); do
image=$(head -n 1 "$dockerfile" | grep '# ' | cut -d' ' -f2)
if test -z "$image"; then image="$IMAGE"; fi
build_docker "$dockerfile" "$image"
done
done