-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
executable file
·62 lines (55 loc) · 1.57 KB
/
test.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
#!/usr/bin/env bash
set -e
declare SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
source $SCRIPTPATH/functions.sh
docker build -t boky/tool-downloader .
do_it() {
if [ -d "$1" ]; then
for i in $1/Dockerfile*; do
do_it "$i"
done
return
fi
local dockerfile="$1"
local dockerdir="$(dirname "$dockerfile")"
local toolname="$(basename "$dockerdir")"
local VERSION="$(echo "$dockerfile" | cut -f2- -d.)"
local IS_LATEST
local build_env="$dockerdir/build.env"
local cmd
local IMAGE_VERSION
if [ "$dockerfile" == "$VERSION" ]; then
IS_LATEST=" (latest)"
cmd="env $(build_args "$build_env") ./files/tool-downloader.sh --echo-version"
echo $cmd
VERSION="$(eval "$cmd")"
fi
export VERSION
IMAGE_VERSION="$(echo "$VERSION" | sed -E 's/^v//' | sed -E 's/\+.*$//')"
echo "**** $dockerfile / $IMAGE_VERSION$IS_LATEST ****"
# --env-file <( env | cut -f1 -d= )
cmd="docker build --build-arg VERSION=$VERSION $(build_args "$build_env" "--build-arg ") -t boky/$toolname:$IMAGE_VERSION -f $dockerfile $dockerdir"
echo "$cmd"
eval "$cmd"
if [ -n "$IS_LATEST" ]; then
docker tag boky/$toolname:$IMAGE_VERSION boky/$toolname:latest
fi
}
if [ "$#" -gt 0 ]; then
while [ "$1" != "" ]; do
do_it "$1"
shift
done
else
for i in tools/*; do
if [ -d "$i" ]; then
# Mutagen / IPFS uses the new buildx syntax and is not compatible with docker build
if ! fgrep -q "FROM --platform=" $i/Dockerfile*; then
echo "Building $i."
do_it "$i"
else
echo "Skipping $i because it's in new dockerx format."
fi
fi
done
fi