From 93754d77eea6270cb438d56d80ed2a5b2f594519 Mon Sep 17 00:00:00 2001 From: Victor Marmol Date: Tue, 15 Jul 2014 17:44:50 -0700 Subject: [PATCH] Make cAdvisor Dockerimage much smaller. Remove old Dockerfiles for deployment and create a new one that only includes the statically linked binaries we need. This creates an image that is ~22MB in size. --- deploy/Dockerfile | 11 +++++++++++ deploy/docker-only/Dockerfile | 9 --------- deploy/lmctfy-docker/Dockerfile | 14 -------------- deploy/prepare.sh | 11 +++++++++++ 4 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 deploy/Dockerfile delete mode 100644 deploy/docker-only/Dockerfile delete mode 100644 deploy/lmctfy-docker/Dockerfile create mode 100644 deploy/prepare.sh diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 00000000..ba8eb614 --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,11 @@ +FROM scratch +MAINTAINER dengnan@google.com vmarmol@google.com + +# NOTE: Run prepare.sh before building this Docker image. + +# Grab lmctfy and cadvisor from the staging directory. +ADD lmctfy /usr/bin/lmctfy +ADD cadvisor /usr/bin/cadvisor + +EXPOSE 8080 +ENTRYPOINT ["/usr/bin/cadvisor"] diff --git a/deploy/docker-only/Dockerfile b/deploy/docker-only/Dockerfile deleted file mode 100644 index a3b18888..00000000 --- a/deploy/docker-only/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM busybox:ubuntu-14.04 -MAINTAINER kyurtsever@google.com dengnan@google.com vmarmol@google.com jason@swindle.me - -# Get cAdvisor binaries. -ADD http://storage.googleapis.com/cadvisor-bin/cadvisor-0.1.3 /usr/bin/cadvisor -RUN chmod +x /usr/bin/cadvisor - -EXPOSE 8080 -ENTRYPOINT ["/usr/bin/cadvisor"] diff --git a/deploy/lmctfy-docker/Dockerfile b/deploy/lmctfy-docker/Dockerfile deleted file mode 100644 index 6060cff0..00000000 --- a/deploy/lmctfy-docker/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ubuntu:14.04 -MAINTAINER kyurtsever@google.com dengnan@google.com vmarmol@google.com - -# Get the lmctfy dependencies. -RUN apt-get update && apt-get install -y -q --no-install-recommends pkg-config libprotobuf8 libapparmor1 - -# Get the lcmtfy and cAdvisor binaries. -ADD http://storage.googleapis.com/cadvisor-bin/lmctfy/lmctfy /usr/bin/lmctfy -ADD http://storage.googleapis.com/cadvisor-bin/lmctfy/libre2.so.0.0.0 /usr/lib/libre2.so.0 -ADD http://storage.googleapis.com/cadvisor-bin/cadvisor-0.1.3 /usr/bin/cadvisor -RUN chmod +x /usr/bin/lmctfy && chmod +x /usr/bin/cadvisor - -EXPOSE 8080 -ENTRYPOINT ["/usr/bin/cadvisor"] diff --git a/deploy/prepare.sh b/deploy/prepare.sh new file mode 100644 index 00000000..8ee35cc3 --- /dev/null +++ b/deploy/prepare.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e +set -x + +# Download lmctfy. +wget http://storage.googleapis.com/cadvisor-bin/lmctfy/lmctfy +chmod +x lmctfy + +# Statically build cAdvisor from source and stage it. +go build --ldflags '-extldflags "-static"' github.com/google/cadvisor