Skip to content

Commit 1f2a8f4

Browse files
committed
cmd/godoc: add cloud build config
Deploys no longer depend on Docker. With only Make and gcloud installed, the following should deploy a new version: $ git clone https://go.googlesource.com/tools $ cd tools $ cd cmd/godoc $ make cloud-build deploy Updates golang/go#27205. Change-Id: I5cc1142e02dc288450d55dbd4da4b30c0a080bd5 Reviewed-on: https://go-review.googlesource.com/c/139240 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent a3d532c commit 1f2a8f4

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

cmd/godoc/Dockerfile.prod

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ RUN echo "requested go ref: ${GO_REF}" >> /goroot/buildinfo
4444
RUN echo "x/tools HEAD: ${TOOLS_HEAD}" >> /goroot/buildinfo
4545
RUN echo "x/tools clean: ${TOOLS_CLEAN}" >> /goroot/buildinfo
4646
RUN echo "image: ${DOCKER_TAG}" >> /goroot/buildinfo
47+
RUN echo "build env: ${BUILD_ENV}" >> /goroot/buildinfo
4748

4849
RUN rm -rf /goroot/.git
4950

cmd/godoc/Makefile

+14-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,23 @@ usage:
1919
@echo "See Makefile and README.godoc-app"
2020
@exit 1
2121

22+
cloud-build: Dockerfile.prod
23+
gcloud builds submit \
24+
--project=$(GCP_PROJECT) \
25+
--config=cloudbuild.yaml \
26+
--substitutions=_GO_REF=$(GO_REF),_TOOLS_HEAD=$(TOOLS_HEAD),_TOOLS_CLEAN=$(TOOLS_CLEAN),_DOCKER_TAG=$(DOCKER_TAG) \
27+
../.. # source code
28+
2229
docker-build: Dockerfile.prod
2330
# NOTE(cbro): move up in directory to include entire tools repo.
31+
# NOTE(cbro): any changes made to this command must also be made in cloudbuild.yaml.
2432
cd ../..; docker build \
25-
-f cmd/godoc/Dockerfile.prod \
26-
--build-arg GO_REF=$(GO_REF) \
27-
--build-arg TOOLS_HEAD=$(TOOLS_HEAD) \
28-
--build-arg TOOLS_CLEAN=$(TOOLS_CLEAN) \
29-
--build-arg DOCKER_TAG=$(DOCKER_TAG) \
33+
-f=cmd/godoc/Dockerfile.prod \
34+
--build-arg=GO_REF=$(GO_REF) \
35+
--build-arg=TOOLS_HEAD=$(TOOLS_HEAD) \
36+
--build-arg=TOOLS_CLEAN=$(TOOLS_CLEAN) \
37+
--build-arg=DOCKER_TAG=$(DOCKER_TAG) \
38+
--build-arg=BUILD_ENV=local \
3039
--tag=$(DOCKER_TAG) \
3140
.
3241

cmd/godoc/README.godoc-app

+5-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ godoc should come up at http://localhost:8080
6666
Deploying to golang.org
6767
-----------------------
6868

69+
Make sure you're signed in to gcloud:
70+
71+
gcloud auth login
72+
6973
Build the image, push it to gcr.io, and deploy to Flex:
7074

71-
make docker-push deploy
75+
make cloud-build deploy
7276

7377
Point the load balancer to the newly deployed version:
7478
(This also runs regression tests)

cmd/godoc/cloudbuild.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright 2018 The Go Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style
3+
# license that can be found in the LICENSE file.
4+
5+
# NOTE(cbro): any changes to the docker command must also be
6+
# made in docker-build in the Makefile.
7+
#
8+
# Variable substitutions must have a preceding underscore. See:
9+
# https://cloud.google.com/cloud-build/docs/configuring-builds/substitute-variable-values#using_user-defined_substitutions
10+
steps:
11+
- name: 'gcr.io/cloud-builders/docker'
12+
args: [
13+
'build',
14+
'-f=cmd/godoc/Dockerfile.prod',
15+
'--build-arg=GO_REF=${_GO_REF}',
16+
'--build-arg=TOOLS_HEAD=${_TOOLS_HEAD}',
17+
'--build-arg=TOOLS_CLEAN=${_TOOLS_CLEAN}',
18+
'--build-arg=DOCKER_TAG=${_DOCKER_TAG}',
19+
'--build-arg=BUILD_ENV=cloudbuild',
20+
'--tag=${_DOCKER_TAG}',
21+
'.',
22+
]
23+
images: ['${_DOCKER_TAG}']
24+
options:
25+
machineType: 'N1_HIGHCPU_8' # building the godoc index takes a lot of memory.

0 commit comments

Comments
 (0)