-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use 2 stage Docker build to shrink final invoker-agent image size
- Loading branch information
1 parent
e080807
commit 2355265
Showing
1 changed file
with
11 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |