From 235526523a61967635749692f1b3c0367ae4b205 Mon Sep 17 00:00:00 2001 From: David Grove Date: Thu, 22 Feb 2018 17:43:13 -0500 Subject: [PATCH] use 2 stage Docker build to shrink final invoker-agent image size --- docker/invoker-agent/Dockerfile | 35 +++++++++++---------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/docker/invoker-agent/Dockerfile b/docker/invoker-agent/Dockerfile index fd7e30b4..029eaea3 100644 --- a/docker/invoker-agent/Dockerfile +++ b/docker/invoker-agent/Dockerfile @@ -1,33 +1,20 @@ -from ubuntu:latest +# build-stage +FROM golang:alpine AS build-env -ENV DOCKER_VERSION 1.12.0 -ENV KUBERNETES_VERSION 1.6.4 - -RUN apt-get -y update && apt-get -y install \ - wget \ - git \ - golang-go - -# Install docker client (for intractive debugging; not actually needed by agent) -RUN wget --no-verbose https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}.tgz && \ -tar --strip-components 1 -xvzf docker-${DOCKER_VERSION}.tgz -C /usr/bin docker/docker && \ -tar --strip-components 1 -xvzf docker-${DOCKER_VERSION}.tgz -C /usr/bin docker/docker-runc && \ -rm -f docker-${DOCKER_VERSION}.tgz && \ -chmod +x /usr/bin/docker && \ -chmod +x /usr/bin/docker-runc - -# Install kubernetes client (for intractive debugging; not actually needed by agent) -RUN wget --no-verbose https://storage.googleapis.com/kubernetes-release/release/v${KUBERNETES_VERSION}/bin/linux/amd64/kubectl && \ -chmod +x kubectl && \ -mv kubectl /usr/bin/kubectl +RUN apk add --no-cache git openssh RUN mkdir -p /openwhisk/src/invoker-agent +COPY main.go /openwhisk/src/invoker-agent ENV GOPATH=/openwhisk +RUN go get github.com/gorilla/mux +RUN go install invoker-agent -COPY main.go /openwhisk/src/invoker-agent -RUN go get --insecure github.com/gorilla/mux -RUN go install invoker-agent +# Final stage +FROM alpine + +RUN mkdir -p /openwhisk/src/invoker-agent +COPY --from=build-env /openwhisk/bin/invoker-agent /openwhisk/bin/invoker-agent CMD ["/openwhisk/bin/invoker-agent"]