ARG ARCH # STEP 1 build executable binary FROM golang:1.16.7-alpine3.13@sha256:eba9c47f522b41337dbac394f18df4b040ba8bdb4e28e4ce0f504780d59acd86 AS builder-amd64 FROM arm32v7/golang:1.16.7-alpine3.13@sha256:1f52cd915cb844d697536be79c45f775daa5e3d954c23c0691938370670ed7dd AS builder-arm FROM arm64v8/golang:1.16.7-alpine3.13@sha256:2ce14a0842a200c1edd14e9535f13b15ca03fd98b237d589f8ca971f10a411a3 AS builder-arm64 FROM builder-${ARCH} AS builder ENV CADVISOR_VERSION="v0.38.8" WORKDIR $GOPATH/src/github.com/google/cadvisor RUN apk upgrade --no-cache \ && apk add libc6-compat device-mapper findutils zfs build-base linux-headers bash git wget curl tar \ && curl -L "https://github.com/google/cadvisor/archive/${CADVISOR_VERSION}.tar.gz" | tar xvz --strip 1 \ && ./build/build.sh # STEP 2 build the image including only the binary FROM alpine:3.14.1@sha256:be9bdc0ef8e96dbc428dc189b31e2e3b05523d96d12ed627c37aa2936653258c AS base-amd64 FROM arm32v7/alpine:3.14.1@sha256:fb9ac82b4cc94c5a6c416a1c656b3ee84df9290ab4106c260eb959997e759e5e AS base-arm FROM arm64v8/alpine:3.14.1@sha256:bd9137c3bb45dbc40cde0f0e19a8b9064c2bc485466221f5e95eb72b0d0cf82e AS base-arm64 FROM base-${ARCH} RUN apk upgrade --no-cache && apk add \ libc6-compat="1.2.2-r3" \ device-mapper="2.02.187-r1" \ findutils="4.8.0-r1" \ zfs="2.0.3-r1" \ && rm -rf /var/cache/apk/* COPY --from=builder /go/src/github.com/google/cadvisor/cadvisor /usr/bin/cadvisor EXPOSE 8080 HEALTHCHECK --interval=30s --timeout=3s CMD wget --quiet --tries=1 --spider http://127.0.0.1:8080/healthz || exit 1 ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]