From f72cf6721d500247591014933d6e7b4738c112dc Mon Sep 17 00:00:00 2001 From: Will McCutchen <will@mccutch.org> Date: Mon, 21 Sep 2020 18:03:51 -0400 Subject: [PATCH] Don't require local gcloud installation --- Makefile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index f9c9c5a..7bbc9e6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean deploy deps image imagepush lint run stagedeploy test testci testcover +.PHONY: clean deploy deps gcloud-auth image imagepush lint run stagedeploy test testci testcover # The version that will be used in docker tags (e.g. to push a # go-httpbin:latest image use `make imagepush VERSION=latest)` @@ -8,6 +8,9 @@ VERSION ?= $(shell git rev-parse --short HEAD) GCLOUD_PROJECT ?= httpbingo GCLOUD_ACCOUNT ?= mccutchen@gmail.com +# Run gcloud in a container to avoid needing to install the SDK locally +GCLOUD_COMMAND ?= docker run --rm -ti --workdir /code -v $$PWD:/code -v $$HOME/.config/gcloud:/root/.config/gcloud google/cloud-sdk gcloud + # Built binaries will be placed here DIST_PATH ?= dist @@ -78,11 +81,14 @@ lint: $(TOOL_GOLINT) $(TOOL_STATICCHECK) # ============================================================================= # deploy & run locally # ============================================================================= -deploy: build - gcloud --account=$(GCLOUD_ACCOUNT) app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --promote +deploy: build gcloud-auth + $(GCLOUD_COMMAND) --account=$(GCLOUD_ACCOUNT) app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --promote + +stagedeploy: build gcloud-auth + $(GCLOUD_COMMAND) --account=$(GCLOUD_ACCOUNT) app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --no-promote -stagedeploy: build - gcloud --account=$(GCLOUD_ACCOUNT) app deploy --quiet --project=$(GCLOUD_PROJECT) --version=$(VERSION) --no-promote +gcloud-auth: + @$(GCLOUD_COMMAND) auth list | grep '^\*' | grep -q $(GCLOUD_ACCOUNT) || $(GCLOUD_COMMAND) auth login $(GCLOUD_ACCOUNT) run: build $(DIST_PATH)/go-httpbin -- GitLab