UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Dockerfile 1.26 KiB
ARG BUILD_BASE_REGISTRY=registry1.dso.mil
ARG BUILD_BASE_IMAGE=ironbank/google/golang
ARG BUILD_BASE_TAG=1.17
ARG BASE_REGISTRY=registry1.dso.mil
ARG BASE_IMAGE=ironbank/google/distroless/static
ARG BASE_TAG=nonroot

FROM $BUILD_BASE_REGISTRY/$BUILD_BASE_IMAGE:$BUILD_BASE_TAG as build-env

ARG VERSION=0.1.12

#WORKDIR /go/src

#ENV GOPATH /go
#ENV PATH $PATH:/go/bin:$GOPATH/bin

ENV REPO github.com/dabealu/zookeeper-exporter
ENV TAG v${VERSION}

#USER root

COPY v${VERSION}.tar.gz /tmp/zookeeper-exporter-${VERSION}.tar.gz

RUN mkdir -p /go/pkg/mod/${REPO}@${TAG} \
    && tar -xvf /tmp/zookeeper-exporter-${VERSION}.tar.gz --strip-components 1 -C /go/pkg/mod/${REPO}@${TAG} 
    ##&& rm -rf /tmp/zookeeper-exporter-${VERSION}.tar.gz

# Build the statically compiled binary
WORKDIR /go/pkg/mod/${REPO}@${TAG}
RUN GO111MODULE=off CGO_ENABLED=0 go build -ldflags='-w -s -extldflags "-static"' -a -o /go/bin/zookeeper-exporter

#######################################
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG}

# Copy our static executable.
COPY --from=build-env --chown=nobody:nobody /go/bin/zookeeper-exporter /go/bin/zookeeper-exporter

EXPOSE 9141

WORKDIR /go/bin
HEALTHCHECK NONE
USER nobody:nobody

# run binary; use vector form
ENTRYPOINT  [ "/go/bin/zookeeper-exporter" ]