forked from fsprojects-archive/zzarchive-docker-fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle-test.sh
49 lines (41 loc) · 1.27 KB
/
circle-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
#!/usr/bin/env bash
# Thanks to https://github.com/influxdata/influxdata-docker
set -e
dir=.
if [ $# -gt 0 ]; then
dir=("$@")
fi
log_msg() {
echo "[$(date "+%Y/%m/%d %H:%M:%S %z")] $@"
}
docker_build() {
# CircleCI cannot build docker images with --rm=true correctly.
if [ -z "$CIRCLE_BUILD_NUM" ]; then
docker build --rm=true "$@"
else
docker build --no-cache --rm=false "$@"
fi
}
log_msg "Verifying docker daemon connectivity"
docker version
failed_builds=()
# Gather directories with a Dockerfile and sanitize the path to remove leading
# a leading ./ and multiple slashes into a single slash.
dockerfiles=$(find "$dir" -name nightly -prune -o -name Dockerfile -print0 | xargs -0 -I{} dirname {} | sed 's@^./@@' | sed 's@//*@/@g')
for path in $dockerfiles; do
# Generate a tag by replacing the first slash with a colon and all remaining slashes with a dash.
tag=$(echo $path | sed 's@/@:@' | sed 's@/@-@g')
log_msg "Building docker image $tag (from $path)"
if ! docker_build -t "$tag" "$path"; then
failed_builds+=("$tag")
fi
done
if [ ${#failed_builds[@]} -eq 0 ]; then
log_msg "All builds succeeded."
else
log_msg "Failed to build the following images:"
for tag in ${failed_builds[@]}; do
echo " $tag"
done
exit ${#failed_builds[@]}
fi