-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·90 lines (76 loc) · 1.62 KB
/
build
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
90
#!/bin/bash
user=${DOCKERUSER:-binaryanalysisplatform}
repo=$user/bap-artifacts
function name_of_path () {
echo "$repo:$1"
}
# create_image path-to-dockerfile
function create_image() {
dir=`dirname $f`
image_name=$(name_of_path $dir)
docker image build $dir -t $image_name
}
function create_images() {
pref=""
if [ "all$1" == "all" ]; then
pref=""
else
pref="$1/"
fi
for d in `ls $1`; do
for f in `find $pref$d -name Dockerfile`; do
create_image $f
done
done
}
# push tag
function push () {
if [ $1 != "<none>" ]; then
docker image push "$repo:$1"
fi
}
function push_images() {
if [ "all$1" == "all" ]; then
for tag in `docker images $repo --format "{{.Tag}}"`; do
push "$tag"
done
else
push "$tag"
fi
}
function generate_summary () {
file=Dockerfile
rm -f $file
function write() {
printf "$1\n" >> $file
}
write 'FROM FROM debian:stable-slim'
write 'WORKDIR /artifacts'
write ''
for tag in `docker images $repo --format "{{.Tag}}"`; do
write "COPY --from=$repo:$tag /artifact/* /artifacts/$tag/ "
done
}
cmd=$1
shift
targets="$@"
if [ "$cmd" == "create" ]; then
if [ "all$targets" == "all" ]; then
create_images
else
for t in "$@"; do
create_images $t
done
fi
elif [ "$cmd" == "push" ]; then
if [ "all$targets" == "all" ]; then
push_images
else
for t in "$@"; do
push_images $t
done
fi
else
echo "don't know what to do with $cmd"
exit 1
fi