-
Notifications
You must be signed in to change notification settings - Fork 27
/
build_dockers.bsh
executable file
·58 lines (50 loc) · 1.34 KB
/
build_dockers.bsh
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
#!/usr/bin/env bash
# Usage:
# ./build_dockers.bsh - Build all the compiling docker images
# ./build_dockers.bsh centos_7 centos_8 - Build only CentOS 7 & 8 image
set -eu
CUR_DIR=$(dirname "${BASH_SOURCE[0]}")
GOLANG_ARCH="amd64"
while [ -n "${1-}" ]
do
case "$1" in
--arch=*)
GOLANG_ARCH="${1#--arch=}"
shift
;;
*)
break
;;
esac
done
: ${GOLANG_VERSION:=1.23.1}
case "$GOLANG_ARCH" in
amd64)
: ${GOLANG_SHA256:=49bbb517cfa9eee677e1e7897f7cf9cfdbcf49e05f61984a2789136de359f9bd}
;;
arm64)
: ${GOLANG_SHA256:=faec7f7f8ae53fda0f3d408f52182d942cc89ef5b7d3d9f23ff117437d4b2d2f}
;;
esac
export GOLANG_VERSION GOLANG_SHA256 GOLANG_ARCH
#If you are not in docker group and you have sudo, default value is sudo
: ${SUDO=`if ( [ ! -w /var/run/docker.sock ] && id -nG | grep -qwv docker && [ "${DOCKER_HOST:+dh}" != "dh" ] ) && which sudo > /dev/null 2>&1; then echo sudo; fi`}
export SUDO
PARALLEL=
if [[ ${1:-} = -j ]]; then
PARALLEL=t
shift
fi
if [[ $# == 0 ]]; then
IMAGE_NAMES=($(ls -d ${CUR_DIR}/*.Dockerfile))
else
IMAGE_NAMES=("${@}")
fi
#This will take a long time the first time
if [[ -n $PARALLEL ]]; then
printf "%s\n" ${IMAGE_NAMES[@]} | parallel --line-buffer -I{} "$CUR_DIR/build_one" {}
else
for IMAGE_NAME in "${IMAGE_NAMES[@]}"; do
"$CUR_DIR/build_one" "$IMAGE_NAME"
done
fi