Multi-arch containerized build for Cadvisor (#2323)

* ppc64le build for cAdvisor
This commit is contained in:
lysannef 2019-12-05 03:37:30 +05:30 committed by David Ashpole
parent 236f41d419
commit d0f2717c77
3 changed files with 37 additions and 4 deletions

View File

@ -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"

View File

@ -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

18
deploy/Dockerfile.ppc64le Normal file
View File

@ -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"]