forked from nodejs/docker-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-build.sh
executable file
·90 lines (69 loc) · 2.18 KB
/
test-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
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
#!/usr/bin/env bash
#
# Run a test build for all images.
set -euo pipefail
. functions.sh
# Convert comma delimited cli arguments to arrays
# E.g. ./test-build.sh 8,10 slim,onbuild
# "8,10" becomes "8 10" and "slim,onbuild" becomes "slim onbuild"
IFS=',' read -ra versions_arg <<<"${1:-}"
IFS=',' read -ra variant_arg <<<"${2:-}"
default_variant=$(get_config "./" "default_variant")
function build() {
local version
local tag
local variant
local full_tag
local path
version="$1"
shift
variant="$1"
shift
tag="$1"
shift
if [ -z "${variant}" ]; then
full_tag="${tag}"
path="${version}/${variant}"
elif [ "${variant}" = "default" ]; then
full_tag="${tag}"
path="${version}"
else
full_tag="${tag}-${variant}"
path="${version}/${variant}"
fi
info "Building ${full_tag}..."
if ! docker build --cpuset-cpus="0,1" -t node:"${full_tag}" "${path}"; then
fatal "Build of ${full_tag} failed!"
fi
info "Build of ${full_tag} succeeded."
info "Testing ${full_tag}"
docker run --rm -v "$PWD/test-image.sh:/usr/local/bin/test.sh" node:"${full_tag}" test.sh "${full_version}"
}
cd "$(cd "${0%/*}" && pwd -P)" || exit
IFS=' ' read -ra versions <<<"$(get_versions . "${versions_arg[@]}")"
if [ ${#versions[@]} -eq 0 ]; then
fatal "No valid versions found!"
fi
for version in "${versions[@]}"; do
# Skip "docs" and other non-docker directories
[ -f "${version}/Dockerfile" ] || [ -a "${version}/${default_variant}/Dockerfile" ] || continue
tag=$(get_tag "${version}")
full_version=$(get_full_version "${version}")
# Required for chakracore
if [ -f "${version}/Dockerfile" ]; then
build "${version}" "default" "${tag}"
fi
# Get supported variants according to the target architecture.
# See details in function.sh
IFS=' ' read -ra variants <<<"$(get_variants "$(dirname "${version}")" "${variant_arg[@]}")"
for variant in "${variants[@]}"; do
# Skip non-docker directories
[ -f "${version}/${variant}/Dockerfile" ] || continue
if [ "${variant}" = "onbuild" ]; then
build "${version}" "${default_variant}" "$tag"
fi
build "${version}" "${variant}" "${tag}"
done
done
info "All builds successful!"
exit 0