From 30f67244147027d70bbe8f527a946babed170941 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Thu, 13 Apr 2017 14:01:41 +0000 Subject: [PATCH] maintner/maintnerd: change Dockerfile to FROM scratch Before: REPOSITORY SIZE gcr.io/go-dashboard-dev/maintnerd 786MB After: REPOSITORY SIZE gcr.io/go-dashboard-dev/maintnerd 8.85MB Updates golang/go#18817 Updates golang/go#19866 Change-Id: Ibfdadbaf043e44b26d5807c1da45746e934a7dce Reviewed-on: https://go-review.googlesource.com/40572 Reviewed-by: Kevin Burke --- maintner/maintnerd/.gitignore | 2 ++ maintner/maintnerd/Dockerfile | 34 ++++----------------------------- maintner/maintnerd/Dockerfile.0 | 30 +++++++++++++++++++++++++++++ maintner/maintnerd/Makefile | 30 ++++++++++++++++++++++++----- 4 files changed, 61 insertions(+), 35 deletions(-) create mode 100644 maintner/maintnerd/.gitignore create mode 100644 maintner/maintnerd/Dockerfile.0 diff --git a/maintner/maintnerd/.gitignore b/maintner/maintnerd/.gitignore new file mode 100644 index 0000000000..c55f43a579 --- /dev/null +++ b/maintner/maintnerd/.gitignore @@ -0,0 +1,2 @@ +maintnerd +ca-certificates.crt diff --git a/maintner/maintnerd/Dockerfile b/maintner/maintnerd/Dockerfile index f8a5976bc0..4940d7f9f1 100644 --- a/maintner/maintnerd/Dockerfile +++ b/maintner/maintnerd/Dockerfile @@ -1,35 +1,9 @@ # Copyright 2017 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -FROM golang:1.8 +FROM scratch LABEL maintainer "golang-dev@googlegroups.com" -# TODO (jessfraz): change this, gitmirror, and coordinator to have minimal -# builds with a nested build Dockerfile/Makefile - -RUN go get -d golang.org/x/oauth2 -RUN cd /go/src/golang.org/x/oauth2 && git reset --hard 314dd2c0bf3ebd592ec0d20847d27e79d0dbe8dd - -RUN go get -d golang.org/x/net/context -RUN cd /go/src/golang.org/x/net && git reset --hard f2499483f923065a842d38eb4c7f1927e6fc6e6d - -RUN go get -d github.com/google/go-github/github -RUN cd /go/src/github.com/google/go-github && git reset --hard 6896997c7c9fe603fb9d2e8e92303bb18481e60a - -RUN go get -d github.com/gregjones/httpcache -RUN cd /go/src/github.com/gregjones/httpcache && git reset --hard d02018f006d98f58512bf3adfc171d88d17626df - -RUN go get -d go4.org/types -RUN cd /go/src/go4.org && git reset --hard 7ce08ca145dbe0e66a127c447b80ee7914f3e4f9 - -RUN go get -d golang.org/x/sync/errgroup -RUN cd /go/src/golang.org/x/sync && git reset --hard 5a06fca2c336a4b2b2fcb45702e8c47621b2aa2c - -RUN go get -d github.com/golang/protobuf/proto -RUN cd /go/src/github.com/golang/protobuf && git reset --hard 2bba0603135d7d7f5cb73b2125beeda19c09f4ef - -COPY . /go/src/golang.org/x/build/ - -RUN go install golang.org/x/build/maintner/maintnerd - -ENTRYPOINT ["/go/bin/maintnerd"] +COPY ca-certificates.crt /etc/ssl/certs/ +COPY maintnerd / +ENTRYPOINT ["/maintnerd"] diff --git a/maintner/maintnerd/Dockerfile.0 b/maintner/maintnerd/Dockerfile.0 new file mode 100644 index 0000000000..b52d4382d2 --- /dev/null +++ b/maintner/maintnerd/Dockerfile.0 @@ -0,0 +1,30 @@ +# Copyright 2017 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. +FROM golang:1.8 +LABEL maintainer "golang-dev@googlegroups.com" + +RUN go get -d golang.org/x/oauth2 +RUN cd /go/src/golang.org/x/oauth2 && git reset --hard 314dd2c0bf3ebd592ec0d20847d27e79d0dbe8dd + +RUN go get -d golang.org/x/net/context +RUN cd /go/src/golang.org/x/net && git reset --hard f2499483f923065a842d38eb4c7f1927e6fc6e6d + +RUN go get -d github.com/google/go-github/github +RUN cd /go/src/github.com/google/go-github && git reset --hard 6896997c7c9fe603fb9d2e8e92303bb18481e60a + +RUN go get -d github.com/gregjones/httpcache +RUN cd /go/src/github.com/gregjones/httpcache && git reset --hard d02018f006d98f58512bf3adfc171d88d17626df + +RUN go get -d go4.org/types +RUN cd /go/src/go4.org && git reset --hard 7ce08ca145dbe0e66a127c447b80ee7914f3e4f9 + +RUN go get -d golang.org/x/sync/errgroup +RUN cd /go/src/golang.org/x/sync && git reset --hard 5a06fca2c336a4b2b2fcb45702e8c47621b2aa2c + +RUN go get -d github.com/golang/protobuf/proto +RUN cd /go/src/github.com/golang/protobuf && git reset --hard 2bba0603135d7d7f5cb73b2125beeda19c09f4ef + +COPY . /go/src/golang.org/x/build/ + +RUN go install -ldflags "-linkmode=external -extldflags '-static -pthread'" golang.org/x/build/maintner/maintnerd diff --git a/maintner/maintnerd/Makefile b/maintner/maintnerd/Makefile index 02e0773f82..47ecb0bef6 100644 --- a/maintner/maintnerd/Makefile +++ b/maintner/maintnerd/Makefile @@ -2,14 +2,34 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -VERSION=v1 +VERSION=v2 +DOCKER_IMAGE_build0=build0/maintnerd:latest +DOCKER_CTR_build0=maintnerd-build0 -docker-prod: Dockerfile - docker build -f Dockerfile --tag=gcr.io/symbolic-datum-552/maintnerd:$(VERSION) ../.. -docker-dev: Dockerfile - docker build -f Dockerfile --tag=gcr.io/go-dashboard-dev/maintnerd:latest ../.. +build0: *.go Dockerfile.0 + docker build --force-rm -f Dockerfile.0 --tag=$(DOCKER_IMAGE_build0) ../.. + +maintnerd: build0 + docker create --name $(DOCKER_CTR_build0) $(DOCKER_IMAGE_build0) + docker cp $(DOCKER_CTR_build0):/go/bin/$@ $@ + docker rm $(DOCKER_CTR_build0) + +ca-certificates.crt: + docker create --name $(DOCKER_CTR_build0) $(DOCKER_IMAGE_build0) + docker cp $(DOCKER_CTR_build0):/etc/ssl/certs/$@ $@ + docker rm $(DOCKER_CTR_build0) + +docker-prod: Dockerfile maintnerd ca-certificates.crt + docker build --force-rm --tag=gcr.io/symbolic-datum-552/maintnerd:$(VERSION) . +docker-dev: Dockerfile maintnerd ca-certificates.crt + docker build --force-rm --tag=gcr.io/go-dashboard-dev/maintnerd:latest . push-prod: docker-prod gcloud docker -- push gcr.io/symbolic-datum-552/maintnerd:$(VERSION) push-dev: docker-dev gcloud docker -- push gcr.io/go-dashboard-dev/maintnerd:latest + +.PHONY: clean +clean: + $(RM) maintnerd + $(RM) ca-certificates.crt