cmd/{gitmirror,pubsubhelper,gitlock}: use go modules, delete gitlock

This removes the last two gitlock users, so this also deletes gitlock.

And update to multi-stage Dockerfiles, simplifying the build and
making it more consistent with others.

Updates golang/go#26872

Change-Id: I1e38c65eccfe9b8b7cb2d9acd6eb02aa33f8b877
Reviewed-on: https://go-review.googlesource.com/c/build/+/176604
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
diff --git a/cmd/gitlock/README.md b/cmd/gitlock/README.md
deleted file mode 100644
index 9683f58..0000000
--- a/cmd/gitlock/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-<!-- Auto-generated by x/build/update-readmes.go -->
-
-[![GoDoc](https://godoc.org/golang.org/x/build/cmd/gitlock?status.svg)](https://godoc.org/golang.org/x/build/cmd/gitlock)
-
-# golang.org/x/build/cmd/gitlock
-
-The gitlock command helps write Dockerfiles with a bunch of lines to lock git dependencies in place.
diff --git a/cmd/gitlock/gitlock.go b/cmd/gitlock/gitlock.go
deleted file mode 100644
index 410fce2..0000000
--- a/cmd/gitlock/gitlock.go
+++ /dev/null
@@ -1,199 +0,0 @@
-// 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.
-
-// The gitlock command helps write Dockerfiles with a bunch of lines
-// to lock git dependencies in place.
-package main
-
-import (
-	"bufio"
-	"bytes"
-	"flag"
-	"fmt"
-	"go/build"
-	"io"
-	"io/ioutil"
-	"log"
-	"os"
-	"os/exec"
-	"path/filepath"
-	"sort"
-	"strings"
-)
-
-var (
-	ignorePrefixFlag = flag.String("ignore", "golang.org/x/build", "comma-separated list of package prefixes to ignore")
-	updateFile       = flag.String("update", "", "if non-empty, the Dockerfile to update. must have \"# BEGIN deps\" and \"# END deps\" lines.")
-	tags             = flag.String("tags", "", "space-separated tags to pass on to 'go list -tags=XXX target'")
-)
-
-var ignorePrefixes []string
-
-func parseDockerFile() (header, footer []byte) {
-	if *updateFile == "" {
-		return nil, nil
-	}
-	var headBuf, footBuf bytes.Buffer
-	slurp, err := ioutil.ReadFile(*updateFile)
-	if err != nil {
-		log.Fatal(err)
-	}
-	var sawBegin, sawEnd bool
-	bs := bufio.NewScanner(bytes.NewReader(slurp))
-	for bs.Scan() {
-		if !sawBegin {
-			headBuf.Write(bs.Bytes())
-			headBuf.WriteByte('\n')
-			if strings.HasPrefix(bs.Text(), "# BEGIN deps") {
-				sawBegin = true
-				continue
-			}
-			continue
-		}
-		if strings.HasPrefix(bs.Text(), "# END deps") {
-			sawEnd = true
-		}
-		if sawEnd {
-			footBuf.Write(bs.Bytes())
-			footBuf.WriteByte('\n')
-		}
-	}
-	if err := bs.Err(); err != nil {
-		log.Fatalf("error parsing %s: %v", *updateFile, err)
-	}
-	if !sawBegin {
-		log.Fatalf(`file %s is missing a "# BEGIN deps" line`, *updateFile)
-	}
-	if !sawEnd {
-		log.Fatalf(`file %s is missing a "# END deps" line`, *updateFile)
-	}
-	return headBuf.Bytes(), footBuf.Bytes()
-}
-
-func main() {
-	flag.Parse()
-	ignorePrefixes = strings.Split(*ignorePrefixFlag, ",")
-	if flag.NArg() != 1 {
-		log.SetFlags(0)
-		log.Fatalf("Usage: gitlock <package>")
-	}
-	mainPkg := flag.Arg(0) // not necessary "package main", but almost certainly.
-	header, footer := parseDockerFile()
-
-	depOut, err := exec.Command("go", "list",
-		"-tags="+*tags,
-		"-f", "{{range .Deps}}{{.}}\n{{end}}", mainPkg).Output()
-	if err != nil {
-		log.Fatalf("listing deps of %q: %v", mainPkg, formatExecErr(err))
-	}
-
-	var deps []string
-	for _, pkg := range strings.Split(string(depOut), "\n") {
-		if ignorePkg(pkg) {
-			continue
-		}
-		deps = append(deps, pkg)
-	}
-	sort.Strings(deps)
-
-	// Build a map of root git dir => packages using that root git dir.
-	var gitDirPkgs = map[string][]string{}
-	for _, pkg := range deps {
-		buildPkg, err := build.Import(pkg, "", build.FindOnly)
-		if err != nil {
-			log.Fatalf("importing %s: %v", pkg, err)
-		}
-		pkgDir := buildPkg.Dir
-		gitDir, err := findGitDir(pkgDir)
-		if err != nil {
-			log.Fatalf("finding git dir of %s: %v", pkgDir, err)
-		}
-		gitDirPkgs[gitDir] = append(gitDirPkgs[gitDir], pkg)
-	}
-
-	// Sorted list of unique git root dirs.
-	var gitDirs []string
-	for d := range gitDirPkgs {
-		gitDirs = append(gitDirs, d)
-	}
-	sort.Strings(gitDirs)
-
-	var buf bytes.Buffer
-	var out io.Writer = os.Stdout
-	if *updateFile != "" {
-		buf.Write(header)
-		buf.WriteByte('\n')
-		out = &buf
-	}
-	for _, gitDir := range gitDirs {
-		cmd := exec.Command("git", "log", "-n", "1", "--pretty=%H %ci")
-		cmd.Dir = gitDir
-		stdout, err := cmd.Output()
-		if err != nil {
-			log.Fatal(err)
-		}
-		f := strings.SplitN(strings.TrimSpace(string(stdout)), " ", 2)
-		hash, ymd := f[0], f[1][:10]
-
-		repoName := gitDir[strings.Index(gitDir, "/src/")+5:]
-
-		var comment string
-		if n := len(gitDirPkgs[gitDir]); n > 1 {
-			comment = fmt.Sprintf(" `#and %d other pkgs`", n)
-		}
-		fmt.Fprintf(out, "# Repo %s at %s (%s)\n", repoName, hash[:7], ymd)
-		fmt.Fprintf(out, "ENV REV=%s\n", hash)
-		fmt.Fprintf(out, "RUN go get -d %s%s &&\\\n", gitDirPkgs[gitDir][0], comment)
-		fmt.Fprintf(out, "    (cd /go/src/%s && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)\n\n", repoName)
-	}
-
-	fmt.Fprintf(out, "# Optimization to speed up iterative development, not necessary for correctness:\n")
-	fmt.Fprintf(out, "RUN go install %s\n", strings.Join(deps, " \\\n\t"))
-
-	if *updateFile == "" {
-		return
-	}
-	buf.Write(footer)
-	if err := ioutil.WriteFile(*updateFile, buf.Bytes(), 0644); err != nil {
-		log.Fatal(err)
-	}
-}
-
-func findGitDir(dir string) (string, error) {
-	dir0 := dir
-	var lastDir string
-	for dir != "" && dir != "." && dir != lastDir {
-		fi, err := os.Stat(filepath.Join(dir, ".git"))
-		if err == nil && fi.IsDir() {
-			return dir, nil
-		}
-		if err != nil && !os.IsNotExist(err) {
-			return "", err
-		}
-		lastDir = dir
-		dir = filepath.Dir(dir)
-	}
-	return "", fmt.Errorf("no git dir found for %s", dir0)
-}
-
-// ignorePkg reports whether pkg, if it appears as a dependency of the
-// root package, should be omitted from the output.
-func ignorePkg(pkg string) bool {
-	if strings.HasPrefix(pkg, "vendor/") || !strings.Contains(pkg, ".") {
-		return true
-	}
-	for _, pfx := range ignorePrefixes {
-		if strings.HasPrefix(pkg, pfx) {
-			return true
-		}
-	}
-	return false
-}
-
-func formatExecErr(err error) string {
-	if ee, ok := err.(*exec.ExitError); ok && len(ee.Stderr) > 0 {
-		return fmt.Sprintf("%s: %s", err, ee.Stderr)
-	}
-	return fmt.Sprint(err)
-}
diff --git a/cmd/gitmirror/Dockerfile b/cmd/gitmirror/Dockerfile
index 332cea8..d174a64 100644
--- a/cmd/gitmirror/Dockerfile
+++ b/cmd/gitmirror/Dockerfile
@@ -1,7 +1,40 @@
 # 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 debian:jessie
+
+FROM golang:1.12 AS build
+LABEL maintainer "golang-dev@googlegroups.com"
+
+ENV GO111MODULE=on
+ENV GOPROXY=https://proxy.golang.org
+
+RUN mkdir /gocache
+ENV GOCACHE /gocache
+
+COPY go.mod /go/src/golang.org/x/build/go.mod
+COPY go.sum /go/src/golang.org/x/build/go.sum
+
+WORKDIR /go/src/golang.org/x/build
+
+# Optimization for iterative docker build speed, not necessary for correctness:
+# TODO: write a tool to make writing Go module-friendly Dockerfiles easier.
+RUN go install cloud.google.com/go/compute/metadata
+COPY gerrit /go/src/golang.org/x/build/gerrit
+RUN go install golang.org/x/build/gerrit
+COPY buildenv /go/src/golang.org/x/build/buildenv
+RUN go install golang.org/x/build/buildenv
+COPY maintner /go/src/golang.org/x/build/maintner
+COPY cmd/pubsubhelper /go/src/golang.org/x/build/cmd/pubsubhelper
+RUN go install golang.org/x/build/maintner/maintnerd/apipb
+RUN go install golang.org/x/build/maintner/godata
+
+COPY . /go/src/golang.org/x/build/
+WORKDIR /go/src/golang.org/x/build/
+
+COPY . /go/src/golang.org/x/build/
+RUN go install golang.org/x/build/cmd/gitmirror
+
+FROM debian:stretch
 LABEL maintainer "golang-dev@googlegroups.com"
 
 # For interacting with the Go source & subrepos
@@ -10,7 +43,7 @@
 	ca-certificates \
 	git-core \
 	openssh-client \
-	gnupg \
+	gnupg dirmngr \
 	&& rm -rf /var/lib/apt/lists/*
 
 # See https://github.com/golang/go/issues/23705
@@ -30,5 +63,5 @@
 	&& echo "|1|HygGkfOGLovavKfixjXWFJ7Yk1I=|lb/724row8KDTMC1dZiJlHyjxWM= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==" >> ~/.ssh/known_hosts \
 	&& chmod 0600 ~/.ssh/known_hosts
 
-COPY gitmirror /
+COPY --from=build /go/bin/gitmirror /
 ENTRYPOINT ["/tini", "--", "/gitmirror"]
diff --git a/cmd/gitmirror/Dockerfile.0 b/cmd/gitmirror/Dockerfile.0
deleted file mode 100644
index df4b14c..0000000
--- a/cmd/gitmirror/Dockerfile.0
+++ /dev/null
@@ -1,96 +0,0 @@
-# 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.
-
-# Note that OpenSSH 6.5+ is required for the Github SSH private key, which requires
-# at least Debian Jessie (not Wheezy). This uses Jessie:
-FROM golang:1.10
-LABEL maintainer "golang-dev@googlegroups.com"
-
-# BEGIN deps (run `make update-deps` to update)
-
-# Repo cloud.google.com/go at 5e6e482 (2018-06-26)
-ENV REV=5e6e4824f48ade4393d647a2d621fa27238b5954
-RUN go get -d cloud.google.com/go/compute/metadata &&\
-    (cd /go/src/cloud.google.com/go && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/golang/protobuf at 9eb2c01 (2018-06-22)
-ENV REV=9eb2c01ac278a5d89ce4b2be68fe4500955d8179
-RUN go get -d github.com/golang/protobuf/proto `#and 5 other pkgs` &&\
-    (cd /go/src/github.com/golang/protobuf && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/google/go-github at 60d040d (2018-06-23)
-ENV REV=60d040d2dafa18fa3e86cbf22fbc3208ef9ef1e0
-RUN go get -d github.com/google/go-github/github &&\
-    (cd /go/src/github.com/google/go-github && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/google/go-querystring at 53e6ce1 (2017-01-11)
-ENV REV=53e6ce116135b80d037921a7fdd5138cf32d7a8a
-RUN go get -d github.com/google/go-querystring/query &&\
-    (cd /go/src/github.com/google/go-querystring && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/gregjones/httpcache at 9cad4c3 (2018-03-06)
-ENV REV=9cad4c3443a7200dd6400aef47183728de563a38
-RUN go get -d github.com/gregjones/httpcache &&\
-    (cd /go/src/github.com/gregjones/httpcache && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo go4.org at fba789b (2018-01-03)
-ENV REV=fba789b7e39ba524b9e60c45c37a50fae63a2a09
-RUN go get -d go4.org/types &&\
-    (cd /go/src/go4.org && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/net at afe8f62 (2018-06-21)
-ENV REV=afe8f62b1d6bbd81f31868121a50b06d8188e1f9
-RUN go get -d golang.org/x/net/context `#and 2 other pkgs` &&\
-    (cd /go/src/golang.org/x/net && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/oauth2 at ef14785 (2018-06-20)
-ENV REV=ef147856a6ddbb60760db74283d2424e98c87bff
-RUN go get -d golang.org/x/oauth2 `#and 5 other pkgs` &&\
-    (cd /go/src/golang.org/x/oauth2 && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/sync at 1d60e46 (2018-03-14)
-ENV REV=1d60e4601c6fd243af51cc01ddf169918a5407ca
-RUN go get -d golang.org/x/sync/errgroup &&\
-    (cd /go/src/golang.org/x/sync && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/time at fbb02b2 (2018-04-12)
-ENV REV=fbb02b2291d28baffd63558aa44b4b56f178d650
-RUN go get -d golang.org/x/time/rate &&\
-    (cd /go/src/golang.org/x/time && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo google.golang.org/api at 3639d6d (2018-06-21)
-ENV REV=3639d6d93f377f39a1de765fa4ef37b3c7ca8bd9
-RUN go get -d google.golang.org/api/compute/v1 `#and 5 other pkgs` &&\
-    (cd /go/src/google.golang.org/api && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Optimization to speed up iterative development, not necessary for correctness:
-RUN go install cloud.google.com/go/compute/metadata \
-	github.com/golang/protobuf/proto \
-	github.com/golang/protobuf/ptypes \
-	github.com/golang/protobuf/ptypes/any \
-	github.com/golang/protobuf/ptypes/duration \
-	github.com/golang/protobuf/ptypes/timestamp \
-	github.com/google/go-github/github \
-	github.com/google/go-querystring/query \
-	github.com/gregjones/httpcache \
-	go4.org/types \
-	golang.org/x/net/context \
-	golang.org/x/net/context/ctxhttp \
-	golang.org/x/oauth2 \
-	golang.org/x/oauth2/google \
-	golang.org/x/oauth2/internal \
-	golang.org/x/oauth2/jws \
-	golang.org/x/oauth2/jwt \
-	golang.org/x/sync/errgroup \
-	golang.org/x/time/rate \
-	google.golang.org/api/compute/v1 \
-	google.golang.org/api/gensupport \
-	google.golang.org/api/googleapi \
-	google.golang.org/api/googleapi/internal/uritemplates \
-	google.golang.org/api/oauth2/v2
-# END deps
-
-COPY . /go/src/golang.org/x/build/
-
-RUN go install golang.org/x/build/cmd/gitmirror
diff --git a/cmd/gitmirror/Makefile b/cmd/gitmirror/Makefile
index 0cd48e2..d1dcdaa 100644
--- a/cmd/gitmirror/Makefile
+++ b/cmd/gitmirror/Makefile
@@ -8,26 +8,11 @@
 IMAGE_STAGING := gcr.io/go-dashboard-dev/gitmirror
 IMAGE_PROD := gcr.io/symbolic-datum-552/gitmirror
 
-DOCKER_IMAGE_build0=build0/gitmirror:latest
-DOCKER_CTR_build0=gitmirror-build0
-
-build0: *.go Dockerfile.0
-	docker build --force-rm -f Dockerfile.0 --tag=$(DOCKER_IMAGE_build0) ../..
-
-gitmirror: build0
-	docker create --name $(DOCKER_CTR_build0) $(DOCKER_IMAGE_build0)
-	docker cp $(DOCKER_CTR_build0):/go/bin/$@ $@
-	docker rm $(DOCKER_CTR_build0)
-
-update-deps:
-	go install golang.org/x/build/cmd/gitlock
-	gitlock --update=Dockerfile.0 golang.org/x/build/cmd/gitmirror
-
-docker-prod: Dockerfile gitmirror
-	docker build --force-rm --tag=$(IMAGE_PROD):$(VERSION) .
+docker-prod:
+	docker build -f Dockerfile --force-rm --tag=$(IMAGE_PROD):$(VERSION) ../..
 	docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION)
-docker-staging: Dockerfile gitmirror
-	docker build --force-rm --tag=$(IMAGE_STAGING):$(VERSION) .
+docker-staging:
+	docker build -f Dockerfile --force-rm --tag=$(IMAGE_STAGING):$(VERSION) ../..
 	docker tag $(IMAGE_STAGING):$(VERSION) $(IMAGE_STAGING):$(MUTABLE_VERSION)
 
 push-prod: docker-prod
@@ -41,7 +26,3 @@
 	kubectl rolling-update gitmirror-rc --image=$(IMAGE_PROD):$(VERSION)
 deploy-staging: push-staging
 	kubectl rolling-update gitmirror-rc --image=$(IMAGE_STAGING):$(VERSION)
-
-.PHONY: clean
-clean:
-	$(RM) gitmirror
diff --git a/cmd/pubsubhelper/Dockerfile b/cmd/pubsubhelper/Dockerfile
index 402677d..cfff76f 100644
--- a/cmd/pubsubhelper/Dockerfile
+++ b/cmd/pubsubhelper/Dockerfile
@@ -1,9 +1,36 @@
 # 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 scratch
+
+FROM golang:1.12 AS build
 LABEL maintainer "golang-dev@googlegroups.com"
 
-COPY ca-certificates.crt /etc/ssl/certs/
-COPY pubsubhelper /
+ENV GO111MODULE=on
+ENV GOPROXY=https://proxy.golang.org
+
+RUN mkdir /gocache
+ENV GOCACHE /gocache
+
+COPY go.mod /go/src/golang.org/x/build/go.mod
+COPY go.sum /go/src/golang.org/x/build/go.sum
+
+WORKDIR /go/src/golang.org/x/build
+
+# Optimization for iterative docker build speed, not necessary for correctness:
+# TODO: write a tool to make writing Go module-friendly Dockerfiles easier.
+RUN go install cloud.google.com/go/compute/metadata
+RUN go install github.com/bradfitz/go-smtpd/smtpd
+RUN go install github.com/jellevandenhooff/dkim
+RUN go install go4.org/types
+RUN go install golang.org/x/crypto/acme/autocert
+
+COPY . /go/src/golang.org/x/build/
+
+# Install binary to /go/bin:
+RUN go install golang.org/x/build/cmd/pubsubhelper
+
+FROM debian:stretch
+LABEL maintainer "golang-dev@googlegroups.com"
+
+COPY --from=build /go/bin/pubsubhelper /
 ENTRYPOINT ["/pubsubhelper"]
diff --git a/cmd/pubsubhelper/Dockerfile.0 b/cmd/pubsubhelper/Dockerfile.0
deleted file mode 100644
index c8b305e..0000000
--- a/cmd/pubsubhelper/Dockerfile.0
+++ /dev/null
@@ -1,52 +0,0 @@
-# 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.10
-LABEL maintainer "golang-dev@googlegroups.com"
-
-# BEGIN deps (run `make update-deps` to update)
-
-# Repo cloud.google.com/go at 1d0c2da (2018-01-30)
-ENV REV=1d0c2da40456a9b47f5376165f275424acc15c09
-RUN go get -d cloud.google.com/go/compute/metadata &&\
-    (cd /go/src/cloud.google.com/go && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/bradfitz/go-smtpd at deb6d62 (2017-04-04)
-ENV REV=deb6d623762522f8ad4a55b952001e4215a76cf4
-RUN go get -d github.com/bradfitz/go-smtpd/smtpd &&\
-    (cd /go/src/github.com/bradfitz/go-smtpd && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo github.com/jellevandenhooff/dkim at f50fe3d (2015-03-30)
-ENV REV=f50fe3d243e1a9c9369eea29813517f3af190518
-RUN go get -d github.com/jellevandenhooff/dkim &&\
-    (cd /go/src/github.com/jellevandenhooff/dkim && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo go4.org at 034d17a (2017-05-25)
-ENV REV=034d17a462f7b2dcd1a4a73553ec5357ff6e6c6e
-RUN go get -d go4.org/types &&\
-    (cd /go/src/go4.org && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/crypto at 1875d0a (2018-01-27)
-ENV REV=1875d0a70c90e57f11972aefd42276df65e895b9
-RUN go get -d golang.org/x/crypto/acme `#and 2 other pkgs` &&\
-    (cd /go/src/golang.org/x/crypto && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Repo golang.org/x/net at 0ed95ab (2018-01-24)
-ENV REV=0ed95abb35c445290478a5348a7b38bb154135fd
-RUN go get -d golang.org/x/net/context `#and 2 other pkgs` &&\
-    (cd /go/src/golang.org/x/net && (git cat-file -t $REV 2>/dev/null || git fetch -q origin $REV) && git reset --hard $REV)
-
-# Optimization to speed up iterative development, not necessary for correctness:
-RUN go install cloud.google.com/go/compute/metadata \
-	github.com/bradfitz/go-smtpd/smtpd \
-	github.com/jellevandenhooff/dkim \
-	go4.org/types \
-	golang.org/x/crypto/acme \
-	golang.org/x/crypto/acme/autocert \
-	golang.org/x/net/context \
-	golang.org/x/net/context/ctxhttp
-# END deps
-
-COPY . /go/src/golang.org/x/build/
-
-RUN go install -ldflags "-linkmode=external -extldflags '-static -pthread'" golang.org/x/build/cmd/pubsubhelper
diff --git a/cmd/pubsubhelper/Makefile b/cmd/pubsubhelper/Makefile
index cf03a77..c8368a7 100644
--- a/cmd/pubsubhelper/Makefile
+++ b/cmd/pubsubhelper/Makefile
@@ -8,31 +8,11 @@
 IMAGE_STAGING := gcr.io/go-dashboard-dev/pubsubhelper
 IMAGE_PROD := gcr.io/symbolic-datum-552/pubsubhelper
 
-DOCKER_IMAGE_build0=build0/pubsubhelper:latest
-DOCKER_CTR_build0=pubsubhelper-build0
-
-build0: *.go Dockerfile.0
-	docker build --force-rm -f Dockerfile.0 --tag=$(DOCKER_IMAGE_build0) ../..
-
-pubsubhelper: 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)
-
-update-deps:
-	go install golang.org/x/build/cmd/gitlock
-	gitlock --update=Dockerfile.0 golang.org/x/build/cmd/pubsubhelper
-
-docker-prod: Dockerfile pubsubhelper ca-certificates.crt
-	docker build --force-rm --tag=$(IMAGE_PROD):$(VERSION) .
+docker-prod:
+	docker build -f Dockerfile --force-rm --tag=$(IMAGE_PROD):$(VERSION) ../..
 	docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_VERSION)
-docker-staging: Dockerfile pubsubhelper ca-certificates.crt
-	docker build --force-rm --tag=$(IMAGE_STAGING):$(VERSION) .
+docker-staging:
+	docker build -f Dockerfile --force-rm --tag=$(IMAGE_STAGING):$(VERSION) ../..
 	docker tag $(IMAGE_STAGING):$(VERSION) $(IMAGE_STAGING):$(MUTABLE_VERSION)
 
 push-prod: docker-prod
@@ -48,8 +28,3 @@
 deploy-staging: push-staging
 	go install golang.org/x/build/cmd/xb
 	xb --staging kubectl set image deployment/pubsubhelper-deployment pubsubhelper=$(IMAGE_STAGING):$(VERSION)
-
-.PHONY: clean
-clean:
-	$(RM) pubsubhelper
-	$(RM) ca-certificates.crt
diff --git a/maintner/maintnerd/Makefile b/maintner/maintnerd/Makefile
index a289014..e572d44 100644
--- a/maintner/maintnerd/Makefile
+++ b/maintner/maintnerd/Makefile
@@ -31,8 +31,3 @@
 deploy-staging: push-staging
 	go install golang.org/x/build/cmd/xb
 	xb --staging kubectl set image deployment/maintnerd-deployment maintnerd=$(IMAGE_STAGING):$(VERSION)
-
-.PHONY: clean
-clean:
-	$(RM) maintnerd
-	$(RM) ca-certificates.crt