2018-09-04 10:55:45 -06:00
|
|
|
# Copyright 2018 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.
|
|
|
|
|
|
|
|
.PHONY: usage
|
|
|
|
|
2018-10-02 03:08:51 -06:00
|
|
|
GO_REF ?= release-branch.go1.11
|
|
|
|
TOOLS_HEAD := $(shell git rev-parse HEAD)
|
|
|
|
TOOLS_CLEAN := $(shell (git status --porcelain | grep -q .) && echo dirty || echo clean)
|
|
|
|
ifeq ($(TOOLS_CLEAN),clean)
|
|
|
|
DOCKER_VERSION ?= $(TOOLS_HEAD)
|
|
|
|
else
|
|
|
|
DOCKER_VERSION ?= $(TOOLS_HEAD)-dirty
|
|
|
|
endif
|
|
|
|
GCP_PROJECT := golang-org
|
|
|
|
DOCKER_TAG := gcr.io/$(GCP_PROJECT)/godoc:$(DOCKER_VERSION)
|
|
|
|
|
2018-09-04 10:55:45 -06:00
|
|
|
usage:
|
2018-10-02 19:41:55 -06:00
|
|
|
@echo "See Makefile and README.godoc-app"
|
|
|
|
@exit 1
|
2018-09-04 10:55:45 -06:00
|
|
|
|
2018-10-02 23:21:05 -06:00
|
|
|
cloud-build: Dockerfile.prod
|
|
|
|
gcloud builds submit \
|
|
|
|
--project=$(GCP_PROJECT) \
|
|
|
|
--config=cloudbuild.yaml \
|
|
|
|
--substitutions=_GO_REF=$(GO_REF),_TOOLS_HEAD=$(TOOLS_HEAD),_TOOLS_CLEAN=$(TOOLS_CLEAN),_DOCKER_TAG=$(DOCKER_TAG) \
|
|
|
|
../.. # source code
|
|
|
|
|
2018-10-02 23:21:05 -06:00
|
|
|
docker-build: Dockerfile.prod
|
2018-10-02 03:08:51 -06:00
|
|
|
# NOTE(cbro): move up in directory to include entire tools repo.
|
2018-10-02 23:21:05 -06:00
|
|
|
# NOTE(cbro): any changes made to this command must also be made in cloudbuild.yaml.
|
2018-10-02 03:08:51 -06:00
|
|
|
cd ../..; docker build \
|
2018-10-02 23:21:05 -06:00
|
|
|
-f=cmd/godoc/Dockerfile.prod \
|
|
|
|
--build-arg=GO_REF=$(GO_REF) \
|
|
|
|
--build-arg=TOOLS_HEAD=$(TOOLS_HEAD) \
|
|
|
|
--build-arg=TOOLS_CLEAN=$(TOOLS_CLEAN) \
|
|
|
|
--build-arg=DOCKER_TAG=$(DOCKER_TAG) \
|
|
|
|
--build-arg=BUILD_ENV=local \
|
2018-10-02 03:08:51 -06:00
|
|
|
--tag=$(DOCKER_TAG) \
|
|
|
|
.
|
2018-09-04 10:55:45 -06:00
|
|
|
|
2018-10-02 23:21:05 -06:00
|
|
|
docker-push: docker-build
|
2018-10-02 03:08:51 -06:00
|
|
|
docker push $(DOCKER_TAG)
|
2018-09-04 10:55:45 -06:00
|
|
|
|
2018-10-02 23:21:05 -06:00
|
|
|
deploy:
|
2018-10-02 03:08:51 -06:00
|
|
|
gcloud -q app deploy app.prod.yaml \
|
2018-10-02 23:21:05 -06:00
|
|
|
--project=$(GCP_PROJECT) \
|
2018-10-02 03:08:51 -06:00
|
|
|
--no-promote \
|
2018-10-02 23:21:05 -06:00
|
|
|
--image-url=$(DOCKER_TAG)
|
2018-09-04 10:55:45 -06:00
|
|
|
|
|
|
|
get-latest-url:
|
2018-10-02 03:08:51 -06:00
|
|
|
@gcloud app versions list \
|
2018-10-02 23:21:05 -06:00
|
|
|
--service=default \
|
|
|
|
--project=$(GCP_PROJECT) \
|
2018-10-02 03:08:51 -06:00
|
|
|
--sort-by=~version.createTime \
|
|
|
|
--format='value(version.versionUrl)' \
|
|
|
|
--limit 1 | cut -f1 # NOTE(cbro): gcloud prints out createTime as the second field.
|
2018-09-04 10:55:45 -06:00
|
|
|
|
2018-10-02 23:21:05 -06:00
|
|
|
get-latest-id:
|
|
|
|
@gcloud app versions list \
|
|
|
|
--service=default \
|
|
|
|
--project=$(GCP_PROJECT) \
|
|
|
|
--sort-by=~version.createTime \
|
|
|
|
--format='value(version.id)' \
|
|
|
|
--limit 1 | cut -f1 # NOTE(cbro): gcloud prints out createTime as the second field.
|
|
|
|
|
2018-09-04 10:55:45 -06:00
|
|
|
regtest:
|
2018-10-02 19:41:55 -06:00
|
|
|
go test -v \
|
|
|
|
-regtest.host=$(shell make get-latest-url) \
|
|
|
|
-run=Live
|
2018-10-02 23:21:05 -06:00
|
|
|
|
|
|
|
publish: regtest
|
|
|
|
gcloud -q app services set-traffic default \
|
|
|
|
--splits=$(shell make get-latest-id)=1 \
|
|
|
|
--project=$(GCP_PROJECT)
|
|
|
|
|
|
|
|
@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
@echo Stop and/or delete old versions:
|
|
|
|
@echo "https://console.cloud.google.com/appengine/versions?project=$(GCP_PROJECT)&serviceId=default&versionssize=50"
|
|
|
|
@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|