From 3bfafa2f4c4ecbbe3f567632fcf9bbbd2d7da063 Mon Sep 17 00:00:00 2001 From: Jon Friesen Date: Fri, 14 Sep 2018 13:36:30 -0700 Subject: [PATCH] make coredns/Dockerfile use build stages (#424) * make coredns/Dockerfile use build stages This change makes the coredns Dockerfile use build stages to create the binaries which are then copied to the image for running. * removing deps --- coredns/Dockerfile | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/coredns/Dockerfile b/coredns/Dockerfile index c758c7a..0348f2c 100644 --- a/coredns/Dockerfile +++ b/coredns/Dockerfile @@ -1,32 +1,31 @@ -FROM alpine:latest +FROM alpine:latest as builder LABEL maintainer "Jessie Frazelle " ENV PATH /go/bin:/usr/local/go/bin:$PATH ENV GOPATH /go -RUN apk --no-cache add \ - ca-certificates +RUN apk --no-cache add \ + ca-certificates ENV COREDNS_VERSION v1.2.2 -RUN buildDeps=' \ - go \ - git \ - gcc \ - g++ \ - libc-dev \ - libgcc \ - make \ - ' \ - set -x \ - && apk --no-cache add $buildDeps \ - && git clone --depth 1 --branch ${COREDNS_VERSION} https://github.com/coredns/coredns /go/src/github.com/coredns/coredns \ - && cd /go/src/github.com/coredns/coredns \ - && make CHECKS="godeps" \ - && mv coredns /usr/bin/coredns \ - && apk del $buildDeps \ - && rm -rf /go \ - && echo "Build complete." +RUN set -x \ + && apk --no-cache add \ + go \ + git \ + gcc \ + g++ \ + libc-dev \ + libgcc \ + make \ + && git clone --depth 1 --branch ${COREDNS_VERSION} https://github.com/coredns/coredns /go/src/github.com/coredns/coredns \ + && cd /go/src/github.com/coredns/coredns \ + && make CHECKS="godeps" \ + && mv coredns /usr/bin/coredns \ + && echo "Build complete." +FROM alpine:latest -ENTRYPOINT [ "coredns", "-log" ] +COPY --from=builder /usr/bin/coredns /usr/bin/coredns + +ENTRYPOINT [ "coredns", "-log" ] \ No newline at end of file