From afc3bf64c0db903a40b476ab867e02168806f839 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Mon, 8 Sep 2014 15:35:40 -0700 Subject: [PATCH] dashboard: optimize linux docker image size LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://golang.org/cl/132590043 --- dashboard/env/linux-x86-base/Dockerfile | 37 ++--------------- dashboard/env/linux-x86-base/Makefile | 3 ++ .../scripts/build-go-builder.sh | 20 ++++++++++ .../scripts/install-apt-deps.sh | 17 ++++++++ dashboard/env/linux-x86-nacl/Dockerfile | 40 ++----------------- dashboard/env/linux-x86-nacl/Makefile | 3 ++ .../scripts/build-go-builder.sh | 26 ++++++++++++ .../scripts/install-apt-deps.sh | 14 +++++++ 8 files changed, 91 insertions(+), 69 deletions(-) create mode 100755 dashboard/env/linux-x86-base/scripts/build-go-builder.sh create mode 100755 dashboard/env/linux-x86-base/scripts/install-apt-deps.sh create mode 100755 dashboard/env/linux-x86-nacl/scripts/build-go-builder.sh create mode 100755 dashboard/env/linux-x86-nacl/scripts/install-apt-deps.sh diff --git a/dashboard/env/linux-x86-base/Dockerfile b/dashboard/env/linux-x86-base/Dockerfile index 4aa6dacb4c5..9151d89019d 100644 --- a/dashboard/env/linux-x86-base/Dockerfile +++ b/dashboard/env/linux-x86-base/Dockerfile @@ -8,38 +8,9 @@ FROM debian:wheezy MAINTAINER golang-dev ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get upgrade -y -# For running curl to get the hg starter tarballs (faster than hg clone). -RUN apt-get install -y --no-install-recommends curl ca-certificates +ADD /scripts/install-apt-deps.sh /scripts/ +RUN /scripts/install-apt-deps.sh -# Optionally used by some net/http tests: -RUN apt-get install -y --no-install-recommends strace - -# For building Go's bootstrap 'dist' program: -RUN apt-get install -y --no-install-recommends gcc libc6-dev - -# For 32-bit builds: -# TODO(bradfitz): move these into a 386 image that derives from this one. -RUN apt-get install -y --no-install-recommends libc6-dev-i386 gcc-multilib - -# For interacting with the Go source & subrepos: -RUN apt-get install -y --no-install-recommends mercurial git-core - -ENV GOPATH /gopath -ENV GOROOT /goroot - -RUN mkdir -p $GOROOT -RUN cd $GOROOT && curl -s https://storage.googleapis.com/gobuilder/go-snap.tar.gz | tar x --no-same-owner -zv - -ENV GO_TOOLS $GOPATH/src/code.google.com/p/go.tools -RUN mkdir -p $GO_TOOLS -RUN cd $GO_TOOLS $ && curl -s https://storage.googleapis.com/gobuilder/go.tools-snap.tar.gz | tar x --no-same-owner -zv - -RUN cd $GOROOT && hg pull && hg update -C b8ff0ec2a724 -RUN cd $GOROOT/src && ./make.bash -RUN mkdir -p /usr/local/bin - -RUN cd $GO_TOOLS && hg pull && hg update -C f9e37a924785 -ENV GOBIN /usr/local/bin -RUN /goroot/bin/go install code.google.com/p/go.tools/dashboard/builder +ADD /scripts/build-go-builder.sh /scripts/ +RUN GO_REV=073fc578434b BUILDER_REV=8845ca94a310 /scripts/build-go-builder.sh && test -f /usr/local/bin/builder diff --git a/dashboard/env/linux-x86-base/Makefile b/dashboard/env/linux-x86-base/Makefile index 4286d210b5d..7b4685eace8 100644 --- a/dashboard/env/linux-x86-base/Makefile +++ b/dashboard/env/linux-x86-base/Makefile @@ -7,3 +7,6 @@ docker: Dockerfile docker-linux.base.tar.gz: docker docker save gobuilders/linux-x86-base | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.base.tar.gz) + +check: docker + docker run gobuilders/linux-x86-base /usr/local/bin/builder -rev=073fc578434b -buildroot=/ -v -report=false linux-amd64-temp diff --git a/dashboard/env/linux-x86-base/scripts/build-go-builder.sh b/dashboard/env/linux-x86-base/scripts/build-go-builder.sh new file mode 100755 index 00000000000..1448fc567ea --- /dev/null +++ b/dashboard/env/linux-x86-base/scripts/build-go-builder.sh @@ -0,0 +1,20 @@ +set -ex + +export GOPATH=/gopath +export GOROOT=/goroot +PREFIX=/usr/local +: ${GO_REV:?"need to be set to the golang repo revision used to build the builder."} +: ${BUILDER_REV:?"need to be set to the go.tools repo revision for the builder."} + +mkdir -p $GOROOT +curl -s https://storage.googleapis.com/gobuilder/go-snap.tar.gz | tar x --no-same-owner -zv -C $GOROOT +(cd $GOROOT/src && hg pull -r $GO_REV -u && find && ./make.bash) + +GO_TOOLS=$GOPATH/src/code.google.com/p/go.tools +mkdir -p $GO_TOOLS +curl -s https://storage.googleapis.com/gobuilder/go.tools-snap.tar.gz | tar x --no-same-owner -zv -C $GO_TOOLS + +mkdir -p $PREFIX/bin +(cd $GO_TOOLS && hg pull -r $BUILDER_REV -u && GOBIN=$PREFIX/bin /goroot/bin/go install code.google.com/p/go.tools/dashboard/builder) + +rm -fR $GOROOT/bin $GOROOT/pkg $GOPATH diff --git a/dashboard/env/linux-x86-base/scripts/install-apt-deps.sh b/dashboard/env/linux-x86-base/scripts/install-apt-deps.sh new file mode 100755 index 00000000000..839f4ad2fa0 --- /dev/null +++ b/dashboard/env/linux-x86-base/scripts/install-apt-deps.sh @@ -0,0 +1,17 @@ +set -ex + +apt-get update +# For running curl to get the hg starter tarballs (faster than hg clone). +apt-get install -y --no-install-recommends curl ca-certificates +# Optionally used by some net/http tests: +apt-get install -y --no-install-recommends strace +# For building Go's bootstrap 'dist' prog +apt-get install -y --no-install-recommends gcc libc6-dev +# For 32-bit builds: +# TODO(bradfitz): move these into a 386 image that derives from this one. +apt-get install -y --no-install-recommends libc6-dev-i386 gcc-multilib +# For interacting with the Go source & subrepos: +apt-get install -y --no-install-recommends mercurial git-core + +apt-get clean +rm -fr /var/lib/apt/lists diff --git a/dashboard/env/linux-x86-nacl/Dockerfile b/dashboard/env/linux-x86-nacl/Dockerfile index c290c6a9b14..58c673756e6 100644 --- a/dashboard/env/linux-x86-nacl/Dockerfile +++ b/dashboard/env/linux-x86-nacl/Dockerfile @@ -16,44 +16,12 @@ MAINTAINER golang-dev ENV DEBIAN_FRONTEND noninteractive -RUN echo cachebuster4 -RUN apt-get update && apt-get upgrade -y +ADD /scripts/install-apt-deps.sh /scripts/ +RUN /scripts/install-apt-deps.sh -# For running curl to get the hg starter tarballs (faster than hg clone). -RUN apt-get install -y --no-install-recommends curl ca-certificates +ADD /scripts/build-go-builder.sh /scripts/ +RUN GO_REV=073fc578434b BUILDER_REV=8845ca94a310 /scripts/build-go-builder.sh && test -f /usr/local/bin/builder -# For building Go's bootstrap 'dist' program: -RUN apt-get install -y --no-install-recommends gcc libc6-dev - -# For interacting with the Go source & subrepos: -RUN apt-get install -y --no-install-recommends mercurial git-core - -# For 32-bit nacl: -RUN apt-get install -y --no-install-recommends libc6-i386 libc6-dev-i386 lib32stdc++6 gcc-multilib - -ENV GOPATH /gopath -ENV GOROOT /goroot - -RUN mkdir -p $GOROOT -RUN cd $GOROOT && curl -s https://storage.googleapis.com/gobuilder/go-snap.tar.gz | tar x --no-same-owner -zv - -ENV GO_TOOLS $GOPATH/src/code.google.com/p/go.tools -RUN mkdir -p $GO_TOOLS -RUN cd $GO_TOOLS $ && curl -s https://storage.googleapis.com/gobuilder/go.tools-snap.tar.gz | tar x --no-same-owner -zv - -RUN cd $GOROOT && hg pull && hg update -C b8ff0ec2a724 -RUN cd $GOROOT/src && ./make.bash -RUN mkdir -p /usr/local/bin - -RUN cd $GO_TOOLS && hg pull && hg update -C f9e37a924785 -ENV GOBIN /usr/local/bin -RUN /goroot/bin/go install code.google.com/p/go.tools/dashboard/builder - -RUN cd /usr/local/bin && curl -s -O https://storage.googleapis.com/gobuilder/sel_ldr_x86_32 && chmod +x sel_ldr_x86_32 -RUN cd /usr/local/bin && curl -s -O https://storage.googleapis.com/gobuilder/sel_ldr_x86_64 && chmod +x sel_ldr_x86_64 - -RUN ln -s $GOROOT/misc/nacl/go_nacl_386_exec /usr/local/bin/ -RUN ln -s $GOROOT/misc/nacl/go_nacl_amd64p32_exec /usr/local/bin/ ADD build-command.pl /usr/local/bin/ ENV PATH /usr/local/bin:$GOROOT/bin:$PATH diff --git a/dashboard/env/linux-x86-nacl/Makefile b/dashboard/env/linux-x86-nacl/Makefile index 738ca806d3d..34cb1eb9a51 100644 --- a/dashboard/env/linux-x86-nacl/Makefile +++ b/dashboard/env/linux-x86-nacl/Makefile @@ -7,3 +7,6 @@ docker: Dockerfile upload: docker docker save gobuilders/linux-x86-nacl | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.nacl.tar.gz) + +check: docker + docker run gobuilders/linux-x86-nacl /usr/local/bin/builder -rev=073fc578434b -buildroot=/ -v -cmd=/usr/local/bin/build-command.pl -report=false nacl-amd64p32-temp diff --git a/dashboard/env/linux-x86-nacl/scripts/build-go-builder.sh b/dashboard/env/linux-x86-nacl/scripts/build-go-builder.sh new file mode 100755 index 00000000000..c4a796239d6 --- /dev/null +++ b/dashboard/env/linux-x86-nacl/scripts/build-go-builder.sh @@ -0,0 +1,26 @@ +set -ex + +export GOPATH=/gopath +export GOROOT=/goroot +PREFIX=/usr/local +: ${GO_REV:?"need to be set to the golang repo revision used to build the builder."} +: ${BUILDER_REV:?"need to be set to the go.tools repo revision for the builder."} + +mkdir -p $GOROOT +curl -s https://storage.googleapis.com/gobuilder/go-snap.tar.gz | tar x --no-same-owner -zv -C $GOROOT +(cd $GOROOT/src && hg pull -r $GO_REV -u && find && ./make.bash) + +GO_TOOLS=$GOPATH/src/code.google.com/p/go.tools +mkdir -p $GO_TOOLS +curl -s https://storage.googleapis.com/gobuilder/go.tools-snap.tar.gz | tar x --no-same-owner -zv -C $GO_TOOLS + +mkdir -p $PREFIX/bin +(cd $GO_TOOLS && hg pull -r $BUILDER_REV -u && GOBIN=$PREFIX/bin /goroot/bin/go install code.google.com/p/go.tools/dashboard/builder) + +rm -fR $GOROOT/bin $GOROOT/pkg $GOPATH + +(cd /usr/local/bin && curl -s -O https://storage.googleapis.com/gobuilder/sel_ldr_x86_32 && chmod +x sel_ldr_x86_32) +(cd /usr/local/bin && curl -s -O https://storage.googleapis.com/gobuilder/sel_ldr_x86_64 && chmod +x sel_ldr_x86_64) + +ln -s $GOROOT/misc/nacl/go_nacl_386_exec /usr/local/bin/ +ln -s $GOROOT/misc/nacl/go_nacl_amd64p32_exec /usr/local/bin/ diff --git a/dashboard/env/linux-x86-nacl/scripts/install-apt-deps.sh b/dashboard/env/linux-x86-nacl/scripts/install-apt-deps.sh new file mode 100755 index 00000000000..f5186467618 --- /dev/null +++ b/dashboard/env/linux-x86-nacl/scripts/install-apt-deps.sh @@ -0,0 +1,14 @@ +set -ex + +apt-get update +# For running curl to get the hg starter tarballs (faster than hg clone). +apt-get install -y --no-install-recommends curl ca-certificates +# For building Go's bootstrap 'dist' prog +apt-get install -y --no-install-recommends gcc libc6-dev +# For interacting with the Go source & subrepos: +apt-get install -y --no-install-recommends mercurial git-core +# For 32-bit nacl: +apt-get install -y --no-install-recommends libc6-i386 libc6-dev-i386 lib32stdc++6 gcc-multilib + +apt-get clean +rm -fr /var/lib/apt/lists