diff --git a/Makefile b/Makefile index 34fe625c..119b8465 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,14 @@ GO := go pkgs = $(shell $(GO) list ./... | grep -v vendor) +arch ?= $(shell go env GOARCH) + +ifeq ($(arch), amd64) + Dockerfile_tag := '' +else + Dockerfile_tag := '.''$(arch)' +endif + all: presubmit build test @@ -40,7 +48,7 @@ vet: build: assets @echo ">> building binaries" - @./build/build.sh + @./build/build.sh $(arch) assets: @echo ">> building assets" @@ -50,8 +58,8 @@ release: @echo ">> building release binaries" @./build/release.sh -docker: - @docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile . +docker-%: + @docker build -t cadvisor:$(shell git rev-parse --short HEAD) -f deploy/Dockerfile$(Dockerfile_tag) . presubmit: vet @echo ">> checking go formatting" diff --git a/build/build.sh b/build/build.sh index e80bccbf..1b9b04fe 100755 --- a/build/build.sh +++ b/build/build.sh @@ -20,6 +20,7 @@ GO_FLAGS=${GO_FLAGS:-"-tags netgo"} # Extra go flags to use in the build. BUILD_USER=${BUILD_USER:-"${USER}@${HOSTNAME}"} BUILD_DATE=${BUILD_DATE:-$( date +%Y%m%d-%H:%M:%S )} VERBOSE=${VERBOSE:-} +GOARCH=$1 repo_path="github.com/google/cadvisor" @@ -49,6 +50,12 @@ if [ -n "$VERBOSE" ]; then echo "Building with -ldflags $ldflags" fi -GOBIN=$PWD go build ${GO_FLAGS} -ldflags "${ldflags}" "${repo_path}" + +if [ -z "$GOARCH" ] +then + GOBIN=$PWD go build ${GO_FLAGS} -ldflags "${ldflags}" "${repo_path}" +else + GOBIN=$PWD env GOOS=linux GOARCH=$GOARCH go build ${GO_FLAGS} -ldflags "${ldflags}" "${repo_path}" +fi exit 0 diff --git a/deploy/Dockerfile.ppc64le b/deploy/Dockerfile.ppc64le new file mode 100644 index 00000000..b56b971f --- /dev/null +++ b/deploy/Dockerfile.ppc64le @@ -0,0 +1,18 @@ +FROM ppc64le/alpine:3.10 +MAINTAINER dashpole@google.com lysannef@us.ibm.com + +RUN apk --no-cache add libc6-compat device-mapper findutils zfs && \ + apk --no-cache add thin-provisioning-tools --repository http://dl-3.alpinelinux.org/alpine/edge/main/ && \ + echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ + rm -rf /var/cache/apk/* + +# Grab cadvisor from the staging directory. +ADD cadvisor /usr/bin/cadvisor + +EXPOSE 8080 + +HEALTHCHECK --interval=30s --timeout=3s \ + CMD wget --quiet --tries=1 --spider http://localhost:8080/healthz || exit 1 + +ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"] +