github.com/google/cadvisor@v0.49.1/deploy/Dockerfile (about) 1 FROM registry.hub.docker.com/library/golang:1.22-alpine3.18 AS build 2 3 # Install build depdencies for all supported arches 4 RUN apk --no-cache add bash build-base cmake device-mapper findutils git \ 5 libc6-compat linux-headers ndctl-dev pkgconfig python3 wget zfs && \ 6 apk --no-cache add thin-provisioning-tools --repository http://dl-3.alpinelinux.org/alpine/edge/main/ && \ 7 echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ 8 rm -rf /var/cache/apk/* 9 10 RUN wget https://sourceforge.net/projects/perfmon2/files/libpfm4/libpfm-4.11.0.tar.gz && \ 11 echo "112bced9a67d565ff0ce6c2bb90452516d1183e5 libpfm-4.11.0.tar.gz" | sha1sum -c && \ 12 tar -xzf libpfm-4.11.0.tar.gz && \ 13 rm libpfm-4.11.0.tar.gz 14 15 RUN export DBG="-g -Wall" && \ 16 make -e -C libpfm-4.11.0 && \ 17 make install -C libpfm-4.11.0 18 19 # ipmctl only supports Intel x86_64 processors. 20 # https://github.com/intel/ipmctl/issues/163 21 22 # Disable libipmctl due to https://github.com/google/cadvisor/issues/3482 23 #RUN if [ "$(uname --machine)" = "x86_64" ]; then \ 24 #git clone -b v02.00.00.3885 https://github.com/intel/ipmctl/ && \ 25 #cd ipmctl && \ 26 #mkdir output && \ 27 #cd output && \ 28 #cmake -DRELEASE=ON -DCMAKE_INSTALL_PREFIX=/ -DCMAKE_INSTALL_LIBDIR=/usr/local/lib .. && \ 29 #make -j all && \ 30 #make install; fi 31 32 WORKDIR /go/src/github.com/google/cadvisor 33 34 # Cache Golang Dependencies for faster incremental builds 35 ADD go.mod go.sum ./ 36 RUN go mod download 37 ADD cmd/go.mod cmd/go.sum ./cmd/ 38 RUN cd cmd && go mod download 39 40 ADD . . 41 42 ARG VERSION 43 44 # libipmctl only works on x86_64 CPUs. 45 RUN export GO_TAGS="libpfm,netgo"; \ 46 if [ "$(uname --machine)" = "x86_64" ]; then \ 47 # Disable libipmctl due to https://github.com/google/cadvisor/issues/3482 48 #export GO_TAGS="$GO_TAGS,libipmctl"; \ 49 export GO_TAGS="$GO_TAGS"; \ 50 fi; \ 51 GO_FLAGS="-tags=$GO_TAGS" ./build/build.sh 52 53 FROM mirror.gcr.io/library/alpine:3.18 54 MAINTAINER dengnan@google.com vmarmol@google.com vishnuk@google.com jimmidyson@gmail.com stclair@google.com 55 56 RUN apk --no-cache add libc6-compat device-mapper findutils ndctl zfs && \ 57 apk --no-cache add thin-provisioning-tools --repository http://dl-3.alpinelinux.org/alpine/edge/main/ && \ 58 echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \ 59 rm -rf /var/cache/apk/* 60 61 # Grab cadvisor,libpfm4 and libipmctl from "build" container if they exist (libipmctl only works on amd64/x86_64). 62 COPY --from=build /usr/local/lib/libpfm.so* /usr/local/lib/ 63 COPY --from=build /usr/local/lib/libipmctl.so* /usr/local/lib/ 64 COPY --from=build /go/src/github.com/google/cadvisor/_output/cadvisor /usr/bin/cadvisor 65 66 EXPOSE 8080 67 68 ENV CADVISOR_HEALTHCHECK_URL=http://localhost:8080/healthz 69 70 HEALTHCHECK --interval=30s --timeout=3s \ 71 CMD wget --quiet --tries=1 --spider $CADVISOR_HEALTHCHECK_URL || exit 1 72 73 ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]