Skip to content

Commit

Permalink
fix: move to gcloud builds (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
givanov authored Mar 13, 2020
1 parent c7ba6ab commit 951cfe8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ tags
.vscode/*
.history
# End of https://www.gitignore.io/api/go,vim,emacs,visualstudiocode

# unignore /build/bin
!/build/bin
25 changes: 6 additions & 19 deletions .prow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ presubmits:
containers:
- name: "test-semrelease-dryrun"
imagePullPolicy: IfNotPresent
image: quay.io/ouzi/toolbox:0.1.16
image: quay.io/ouzi/toolbox:0.1.17
command:
- make
args:
Expand All @@ -119,32 +119,19 @@ postsubmits:
- name: credstash-operator-release
labels:
preset-semantic-release: "true"
preset-docker: "true"
preset-gcloud-testinfra-prow: "true"
clone_uri: "[email protected]:ouzi-dev/credstash-operator.git"
decorate: true
max_concurrency: 1
branches:
- master
spec:
nodeSelector:
group_name: image-builder
tolerations:
- key: "imagebuilderonly"
value: "true"
operator: "Equal"
effect: "PreferNoSchedule"
containers:
- name: "release"
imagePullPolicy: Always
image: quay.io/ouzi/kube-dind:18.09
image: quay.io/ouzi/toolbox:0.1.17
command:
- runner.sh
args:
- make
- semantic-release
securityContext:
privileged: true
resources:
requests:
memory: "2Gi"
cpu: 1
args:
- init-gcloud-cli
- semantic-release
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ DOCKER_REPO := quay.io/ouzi/credstash-operator

TMP_VERSION := $(GIT_SHORT_COMMIT)

GCLOUD_KEY_FILE := /etc/google-service-account/service-account.json

ifndef VERSION
ifeq ($(GIT_DIRTY), clean)
ifdef GIT_TAG
Expand Down Expand Up @@ -138,11 +140,13 @@ dist:

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

.PHONY: docker-push
docker-push: docker-build
@docker push $(DOCKER_REPO):${VERSION}
docker-push: clean info
@gcloud builds submit --config build/cloudbuild-push.yaml \
--substitutions=_TAG_VERSION=$(VERSION),_QUAY_REPO=$(DOCKER_REPO) .

.PHONY: clean
clean: helm-clean
Expand Down Expand Up @@ -208,4 +212,12 @@ semantic-release-dry-run:
@npx semantic-release -d

package-lock.json: package.json
@npm install
@npm install

.PHONY: init-gcloud-cli
init-gcloud-cli:
ifneq ("$(wildcard $(GCLOUD_KEY_FILE))","")
gcloud auth activate-service-account --key-file=$(GCLOUD_KEY_FILE)
else
@echo $(GCLOUD_KEY_FILE) not present
endif
20 changes: 20 additions & 0 deletions build/cloudbuild-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
steps:
- name: "gcr.io/cloud-builders/docker"
id: "login"
entrypoint: "bash"
args: ["-c", "docker login quay.io --username=$$QUAY_USERNAME --password=$$QUAY_TOKEN"]
secretEnv: ["QUAY_USERNAME","QUAY_TOKEN"]
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-t', '${_QUAY_REPO}:${_TAG_VERSION}',
'-t', '${_QUAY_REPO}:latest',
'-f', 'build/Dockerfile',
'.'
]
waitFor: ['login']
secrets:
- kmsKeyName: "projects/ouzidev-testinfra-252513/locations/europe-west4/keyRings/test-infra/cryptoKeys/build"
secretEnv:
QUAY_USERNAME: "CiQAyEpfYvO3SdKEGua39aGoMcPViY6juEDsYlY54JOA2GTtQyESMgDP2uhIGZcHeYDKLNWYDUn19/CoeXB+ccsi8eB46bve5fZy4Fp3fqGAz93yPuljTrpi"
QUAY_TOKEN: "CiQAyEpfYo4sk1hRr+YJOQ3Pt07zfOJgzUXQbKExCI5xEiP0P8gSagDP2uhIF/jOw6z37omW3lAA8SVkzxS/rIXBNhj2O2vLnKiE64aHs+uy5YQdIbgMnCmjXz0ky64HJfNiWF/a9poOnIZv0vgAhOU9+/6ul3DfSeKyHbzc+0aawDmyqiX/acqhmDbURHTvatI="
23 changes: 23 additions & 0 deletions build/cloudbuild-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
steps:
- name: "gcr.io/cloud-builders/docker"
id: "login"
entrypoint: "bash"
args: ["-c", "docker login quay.io --username=$$QUAY_USERNAME --password=$$QUAY_TOKEN"]
secretEnv: ["QUAY_USERNAME","QUAY_TOKEN"]
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-t', '${_QUAY_REPO}:${_TAG_VERSION}',
'-t', '${_QUAY_REPO}:latest',
'-f', 'build/Dockerfile',
'.'
]
waitFor: ['login']
secrets:
- kmsKeyName: "projects/ouzidev-testinfra-252513/locations/europe-west4/keyRings/test-infra/cryptoKeys/build"
secretEnv:
QUAY_USERNAME: "CiQAyEpfYvO3SdKEGua39aGoMcPViY6juEDsYlY54JOA2GTtQyESMgDP2uhIGZcHeYDKLNWYDUn19/CoeXB+ccsi8eB46bve5fZy4Fp3fqGAz93yPuljTrpi"
QUAY_TOKEN: "CiQAyEpfYo4sk1hRr+YJOQ3Pt07zfOJgzUXQbKExCI5xEiP0P8gSagDP2uhIF/jOw6z37omW3lAA8SVkzxS/rIXBNhj2O2vLnKiE64aHs+uy5YQdIbgMnCmjXz0ky64HJfNiWF/a9poOnIZv0vgAhOU9+/6ul3DfSeKyHbzc+0aawDmyqiX/acqhmDbURHTvatI="
images:
- '${_QUAY_REPO}:${_TAG_VERSION}'
- '${_QUAY_REPO}:latest'

0 comments on commit 951cfe8

Please sign in to comment.