Skip to content

Commit

Permalink
use 2 stage Docker build to shrink final invoker-agent image size
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrove-oss committed Feb 22, 2018
1 parent e080807 commit 2355265
Showing 1 changed file with 11 additions and 24 deletions.
35 changes: 11 additions & 24 deletions docker/invoker-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 2355265

Please sign in to comment.