cmd/docker/frontend: include keys and config in frontend deploy

I've created an Upspin user, upspin-frontend@upspin.io, that the
frontend will act as when making requests into Upspin space.
This is necessary for the frontend to serve release binaries.

Change-Id: Ia9d2853f6350e7164bdcd153feec5c3ca1d8ce93
Reviewed-on: https://upspin-review.googlesource.com/10343
Reviewed-by: Rob Pike <r@golang.org>
diff --git a/cloud/docker/frontend/Dockerfile b/cloud/docker/frontend/Dockerfile
index 3e174c9..6dc5018 100644
--- a/cloud/docker/frontend/Dockerfile
+++ b/cloud/docker/frontend/Dockerfile
@@ -1,5 +1,8 @@
 FROM buildpack-deps:jessie-curl
+COPY config /upspin/config
+COPY public.upspinkey /upspin/public.upspinkey
+COPY secret.upspinkey /upspin/secret.upspinkey
 COPY bin/frontend-gcp /frontend-gcp
 COPY src/upspin.io/doc /doc
-ENTRYPOINT ["/frontend-gcp", "-letscache=", "-docpath=/doc", "-http=:80", "-https=:443"]
+ENTRYPOINT ["/frontend-gcp", "-letscache=", "-docpath=/doc", "-http=:80", "-https=:443", "-config=/upspin/config"]
 EXPOSE 80 443
diff --git a/cmd/upspin-deploy-gcp/main.go b/cmd/upspin-deploy-gcp/main.go
index 671ccd1..09ab5e3 100644
--- a/cmd/upspin-deploy-gcp/main.go
+++ b/cmd/upspin-deploy-gcp/main.go
@@ -454,6 +454,12 @@
 			"secrets: /upspin",
 			"keyserver: "+c.endpoint("keyserver"), // So that it knows who it is.
 		)
+	case "frontend":
+		err = writeConfig(dir,
+			"username: "+c.frontendUserName(),
+			"secrets: /upspin",
+			"keyserver: "+c.endpoint("keyserver"),
+		)
 	}
 	if err != nil {
 		return err
@@ -477,6 +483,11 @@
 			"public.upspinkey",
 			"secret.upspinkey",
 		}
+	case "frontend":
+		files = []string{
+			"public.upspinkey",
+			"secret.upspinkey",
+		}
 	}
 	home, err := config.Homedir()
 	if err != nil {
@@ -575,6 +586,14 @@
 	return "upspin-key@" + c.Domain
 }
 
+func (c *Config) frontendUserName() string {
+	if c.inProd() {
+		// HACK: see the comment on inProd.
+		return "upspin-frontend@upspin.io"
+	}
+	return "upspin-frontend@" + c.Domain
+}
+
 func writeConfig(dir string, lines ...string) error {
 	var buf bytes.Buffer
 	for _, s := range lines {