forked from eclipse-che/che-dockerfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·38 lines (31 loc) · 1.29 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
PRIVATE_REPO=${PRIVATE_REPO:-}
images=$(for i in $(find recipes -maxdepth 3 -mindepth 1 -type f -not -path '*/\.*' -name Dockerfile -print ); do a=${i#recipes/}; b=${a%/Dockerfile}; case $b in */*) c=${b/\//:};; *) c=$b:latest;; esac; from=$(grep FROM $i); echo ${from#FROM} eclipse/$c; done | tsort)
external_images=$(echo "$images" | grep -v eclipse/)
eclipse_images=$(echo "$images" | grep eclipse/)
echo -e "Going to Pull the following External Images:\n$external_images"
echo -e "\nThen going to Build the following Eclipse Che Images:\n$eclipse_images\n\n"
function error() {
echo $1 > /dev/stderr
exit 1
}
for image in $external_images; do
docker pull $image || error "Unable to pull image: $image"
if [ "x$PRIVATE_REPO" != "x" ]; then
docker tag $image $PRIVATE_REPO/$image
docker push $PRIVATE_REPO/$image || error "Unable to push image: $image"
fi
done
for image in $eclipse_images; do
a=${image%:latest}
b=${a#eclipse/}
d=recipes/${b/:/\/}
echo $b $d
docker build -t $image $d || error "Unable to build image: $image"
if [ "x$PRIVATE_REPO" != "x" ]; then
docker tag $image $PRIVATE_REPO/$image
docker push $PRIVATE_REPO/$image || error "Unable to push image: $image"
else
docker push $image
fi
done