25 lines
622 B
Bash
Executable File
25 lines
622 B
Bash
Executable File
#! /bin/sh
|
|
|
|
docker_tag="$1"
|
|
src_dir="$2"
|
|
dmsetup="$(which dmsetup)"
|
|
docker="$(which docker)"
|
|
export GOARCH="${GOARCH:-amd64}"
|
|
|
|
if [ -n "$dmsetup" ]; then
|
|
# We will build using make
|
|
make -C "$src_dir" build \
|
|
&& cp "${src_dir}/cadvisor" "./cadvisor-$GOARCH"
|
|
elif [ -n "$docker" ]; then
|
|
# We will build using docker
|
|
docker run --rm -it \
|
|
-v "$(pwd)/${src_dir}:/go/src/github.com/google/cadvisor" \
|
|
-e GOARCH="${GOARCH}" \
|
|
"${docker_tag}-build-env" \
|
|
make build \
|
|
&& cp "${src_dir}/cadvisor" "./cadvisor-$GOARCH"
|
|
else
|
|
echo "Either install build dependencies (dmsetup) or Docker"
|
|
exit 1
|
|
fi
|