cmd/gitmirror: switch to cloud build
Change-Id: I357a047197e8415f892de8e920b72afe54ff6ad7
Reviewed-on: https://go-review.googlesource.com/c/build/+/637156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
diff --git a/cmd/gitmirror/Makefile b/cmd/gitmirror/Makefile
index 8db9e3f..5f02502 100644
--- a/cmd/gitmirror/Makefile
+++ b/cmd/gitmirror/Makefile
@@ -3,29 +3,14 @@
# license that can be found in the LICENSE file.
MUTABLE_VERSION ?= latest
-VERSION ?= $(shell git rev-parse --short HEAD)
+VERSION := $(shell ../coordinator/version.sh)
-IMAGE_STAGING := gcr.io/go-dashboard-dev/gitmirror
IMAGE_PROD := gcr.io/symbolic-datum-552/gitmirror
-docker-prod:
- docker build -f Dockerfile --force-rm --tag=$(IMAGE_PROD):$(VERSION) ../..
- docker tag $(IMAGE_PROD):$(VERSION) $(IMAGE_PROD):$(MUTABLE_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
- docker push $(IMAGE_PROD):$(MUTABLE_VERSION)
- docker push $(IMAGE_PROD):$(VERSION)
-push-staging: docker-staging
- docker push $(IMAGE_STAGING):$(MUTABLE_VERSION)
- docker push $(IMAGE_STAGING):$(VERSION)
+push-prod:
+ gcloud builds submit --project=symbolic-datum-552 --config=cloudbuild.yaml --substitutions=TAG_NAME="$(VERSION)" ../..
deploy-prod: push-prod
- kubectl set image --namespace=prod deployment/gitmirror-serving-deployment gitmirror=$(IMAGE_PROD):$(VERSION)
- kubectl set image --namespace=prod deployment/gitmirror-mirroring-deployment gitmirror=$(IMAGE_PROD):$(VERSION)
-
-deploy-staging: push-staging
- echo "no staging configuration"
- exit 1
+ go install golang.org/x/build/cmd/xb
+ xb --prod kubectl --namespace prod set image deployment/gitmirror-serving-deployment gitmirror=$(IMAGE_PROD):$(VERSION)
+ xb --prod kubectl --namespace prod set image deployment/gitmirror-mirroring-deployment gitmirror=$(IMAGE_PROD):$(VERSION)
diff --git a/cmd/gitmirror/cloudbuild.yaml b/cmd/gitmirror/cloudbuild.yaml
new file mode 100644
index 0000000..7535b38
--- /dev/null
+++ b/cmd/gitmirror/cloudbuild.yaml
@@ -0,0 +1,24 @@
+# Copyright 2024 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.
+
+steps:
+- name: 'gcr.io/cloud-builders/docker'
+ args:
+ - 'build'
+ - '-f'
+ - 'cmd/gitmirror/Dockerfile'
+ - '--build-arg'
+ - 'version=${TAG_NAME}'
+ - '-t'
+ - 'gcr.io/symbolic-datum-552/gitmirror:${TAG_NAME}'
+ - '-t'
+ - 'gcr.io/symbolic-datum-552/gitmirror:latest'
+ - '.'
+- name: 'gcr.io/cloud-builders/docker'
+ args: ['push', 'gcr.io/symbolic-datum-552/gitmirror:${TAG_NAME}']
+images:
+- 'gcr.io/symbolic-datum-552/gitmirror:${TAG_NAME}'
+- 'gcr.io/symbolic-datum-552/gitmirror:latest'
+options:
+ logging: CLOUD_LOGGING_ONLY