github.com/m-lab/tcp-info@v1.9.0/Dockerfile (about)

     1  # An image for building zstd
     2  FROM ubuntu:20.04 as zstd-builder
     3  
     4  # Get zstd source and compile zstd as a static binary.
     5  RUN apt-get update && apt-get update -y && apt-get install -y make gcc libc-dev git
     6  RUN git clone https://github.com/facebook/zstd src
     7  RUN mkdir /pkg && cd /src && make MOREFLAGS="-static" zstd && make DESTDIR=/pkg install
     8  
     9  
    10  # An image for building tcp-info
    11  FROM golang:1.20 as tcp-info-builder
    12  
    13  ENV CGO_ENABLED 0
    14  
    15  # Add the tcp-info code from the local repo.
    16  ADD . /go/src/github.com/m-lab/tcp-info
    17  WORKDIR /go/src/github.com/m-lab/tcp-info
    18  
    19  # Get all of our imports and compile the tcp-info binary into /go/bin
    20  RUN go get -v . && \
    21      go install -v \
    22        -ldflags "-X github.com/m-lab/go/prometheusx.GitShortCommit=$(git log -1 --format=%h)" \
    23        .
    24  
    25  # Build the image containing both binaries.
    26  FROM alpine:3.16
    27  
    28  # Copy the zstd binary and license.
    29  COPY --from=zstd-builder /pkg/usr/local/bin/zstd /bin/zstd
    30  RUN mkdir -p /licenses/zstd
    31  COPY --from=zstd-builder /src/LICENSE /licences/zstd/
    32  
    33  # Copy the tcp-info binary.
    34  COPY --from=tcp-info-builder /go/bin/tcp-info /bin/tcp-info
    35  
    36  # This WORKDIR should be mostly unused, because the tcp-info binary takes a
    37  # flag of the form --output=dir, and we expect all users should pass in that
    38  # flag.
    39  WORKDIR /home
    40  
    41  ENTRYPOINT ["/bin/tcp-info"]