Skip to content

Commit 92f26c3

Browse files
authored
fix: switch to gcloud builds (#7)
1 parent abaccce commit 92f26c3

File tree

5 files changed

+67
-15
lines changed

5 files changed

+67
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,6 @@ tags
7878
.vscode/*
7979
.history
8080
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
81+
82+
# unignore /build/bin
83+
!/build/bin

.prow.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ presubmits:
110110
containers:
111111
- name: "test-semrelease-dryrun"
112112
imagePullPolicy: IfNotPresent
113-
image: quay.io/ouzi/toolbox:0.1.16
113+
image: quay.io/ouzi/toolbox:0.1.17
114114
command:
115115
- make
116116
args:
@@ -119,7 +119,7 @@ postsubmits:
119119
- name: node-tagger-release
120120
labels:
121121
preset-semantic-release: "true"
122-
preset-docker: "true"
122+
preset-gcloud-testinfra-prow: "true"
123123
clone_uri: "git@github.com:ouzi-dev/node-tagger.git"
124124
decorate: true
125125
max_concurrency: 1
@@ -136,15 +136,9 @@ postsubmits:
136136
containers:
137137
- name: "release"
138138
imagePullPolicy: Always
139-
image: quay.io/ouzi/kube-dind:18.09
139+
image: quay.io/ouzi/toolbox:0.1.17
140140
command:
141-
- runner.sh
142-
args:
143141
- make
142+
args:
143+
- init-gcloud-cli
144144
- semantic-release
145-
securityContext:
146-
privileged: true
147-
resources:
148-
requests:
149-
memory: "2Gi"
150-
cpu: 1

Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ DOCKER_REPO := quay.io/ouzi/node-tagger
3636

3737
TMP_VERSION := $(GIT_SHORT_COMMIT)
3838

39+
GCLOUD_KEY_FILE := /etc/google-service-account/service-account.json
40+
3941
ifndef VERSION
4042
ifeq ($(GIT_DIRTY), clean)
4143
ifdef GIT_TAG
@@ -135,11 +137,13 @@ dist:
135137

136138
.PHONY: docker-build
137139
docker-build: clean info
138-
@docker build -t $(DOCKER_REPO):${VERSION} -f build/Dockerfile .
140+
@gcloud builds submit --config build/cloudbuild-build.yaml \
141+
--substitutions=_TAG_VERSION=$(VERSION),_QUAY_REPO=$(DOCKER_REPO) .
139142

140143
.PHONY: docker-push
141-
docker-push: docker-build
142-
@docker push $(DOCKER_REPO):${VERSION}
144+
docker-push: clean info
145+
@gcloud builds submit --config build/cloudbuild-push.yaml \
146+
--substitutions=_TAG_VERSION=$(VERSION),_QUAY_REPO=$(DOCKER_REPO) .
143147

144148
.PHONY: clean
145149
clean: helm-clean
@@ -199,4 +203,12 @@ semantic-release-dry-run:
199203
@npx semantic-release -d
200204

201205
package-lock.json: package.json
202-
@npm install
206+
@npm install
207+
208+
.PHONY: init-gcloud-cli
209+
init-gcloud-cli:
210+
ifneq ("$(wildcard $(GCLOUD_KEY_FILE))","")
211+
gcloud auth activate-service-account --key-file=$(GCLOUD_KEY_FILE)
212+
else
213+
@echo $(GCLOUD_KEY_FILE) not present
214+
endif

build/cloudbuild-build.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
steps:
2+
- name: "gcr.io/cloud-builders/docker"
3+
id: "login"
4+
entrypoint: "bash"
5+
args: ["-c", "docker login quay.io --username=$$QUAY_USERNAME --password=$$QUAY_TOKEN"]
6+
secretEnv: ["QUAY_USERNAME","QUAY_TOKEN"]
7+
- name: 'gcr.io/cloud-builders/docker'
8+
args: [
9+
'build',
10+
'-t', '${_QUAY_REPO}:${_TAG_VERSION}',
11+
'-t', '${_QUAY_REPO}:latest',
12+
'-f', 'build/Dockerfile',
13+
'.'
14+
]
15+
waitFor: ['login']
16+
secrets:
17+
- kmsKeyName: "projects/ouzidev-testinfra-252513/locations/europe-west4/keyRings/test-infra/cryptoKeys/build"
18+
secretEnv:
19+
QUAY_USERNAME: "CiQAyEpfYvO3SdKEGua39aGoMcPViY6juEDsYlY54JOA2GTtQyESMgDP2uhIGZcHeYDKLNWYDUn19/CoeXB+ccsi8eB46bve5fZy4Fp3fqGAz93yPuljTrpi"
20+
QUAY_TOKEN: "CiQAyEpfYo4sk1hRr+YJOQ3Pt07zfOJgzUXQbKExCI5xEiP0P8gSagDP2uhIF/jOw6z37omW3lAA8SVkzxS/rIXBNhj2O2vLnKiE64aHs+uy5YQdIbgMnCmjXz0ky64HJfNiWF/a9poOnIZv0vgAhOU9+/6ul3DfSeKyHbzc+0aawDmyqiX/acqhmDbURHTvatI="

build/cloudbuild-push.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
steps:
2+
- name: "gcr.io/cloud-builders/docker"
3+
id: "login"
4+
entrypoint: "bash"
5+
args: ["-c", "docker login quay.io --username=$$QUAY_USERNAME --password=$$QUAY_TOKEN"]
6+
secretEnv: ["QUAY_USERNAME","QUAY_TOKEN"]
7+
- name: 'gcr.io/cloud-builders/docker'
8+
args: [
9+
'build',
10+
'-t', '${_QUAY_REPO}:${_TAG_VERSION}',
11+
'-t', '${_QUAY_REPO}:latest',
12+
'-f', 'build/Dockerfile',
13+
'.'
14+
]
15+
waitFor: ['login']
16+
secrets:
17+
- kmsKeyName: "projects/ouzidev-testinfra-252513/locations/europe-west4/keyRings/test-infra/cryptoKeys/build"
18+
secretEnv:
19+
QUAY_USERNAME: "CiQAyEpfYvO3SdKEGua39aGoMcPViY6juEDsYlY54JOA2GTtQyESMgDP2uhIGZcHeYDKLNWYDUn19/CoeXB+ccsi8eB46bve5fZy4Fp3fqGAz93yPuljTrpi"
20+
QUAY_TOKEN: "CiQAyEpfYo4sk1hRr+YJOQ3Pt07zfOJgzUXQbKExCI5xEiP0P8gSagDP2uhIF/jOw6z37omW3lAA8SVkzxS/rIXBNhj2O2vLnKiE64aHs+uy5YQdIbgMnCmjXz0ky64HJfNiWF/a9poOnIZv0vgAhOU9+/6ul3DfSeKyHbzc+0aawDmyqiX/acqhmDbURHTvatI="
21+
images:
22+
- '${_QUAY_REPO}:${_TAG_VERSION}'
23+
- '${_QUAY_REPO}:latest'

0 commit comments

Comments
 (0)