Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tools/cloudbuild/ko/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# syntax=docker/dockerfile:1

FROM golang:latest

ENV KO_VERSION="0.17.1"
ENV KO_CHECKSUM="4f0b979b59880b3232f47d79c940f2279165aaad15a11d7614e8a2c9e5c78c29"

ADD --checksum=sha256:${KO_CHECKSUM} \
https://github.com/ko-build/ko/releases/download/v${KO_VERSION}/ko_${KO_VERSION}_Linux_x86_64.tar.gz \
ko.tar.gz
RUN tar xf ko.tar.gz -C / ko && chmod +x /ko
40 changes: 24 additions & 16 deletions tools/cloudbuild/pr-open.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,32 @@ steps:
entrypoint: 'npm'
args: ['--prefix', 'web/', 'run', 'build']

# prefetch the ko builder image
- name: gcr.io/$PROJECT_ID/ko
id: ko-prefetch
entrypoint: /bin/sh
args:
- -c
- |
/ko version
- name: 'docker'
id: 'docker-buildx-create'
args: ['buildx', 'create', '--driver', 'docker-container', '--use']
waitFor: ['-']

- name: gcr.io/$PROJECT_ID/ko
id: ko-build
entrypoint: /bin/sh
- name: 'docker'
id: 'docker-build-ko'
args:
- buildx
- build
- tools/cloudbuild/ko/
- --push
- -t
- us.gcr.io/${PROJECT_ID}/ko-builder:${BUILD_ID}
- --cache-to
- type=registry,ref=us.gcr.io/$PROJECT_ID/ko-builder-cache
- --cache-from
- type=registry,ref=us.gcr.io/$PROJECT_ID/ko-builder-cache

- name: 'us.gcr.io/${PROJECT_ID}/ko-builder:${BUILD_ID}'
id: 'ko-build'
env:
- 'KO_DOCKER_REPO=gcr.io/$PROJECT_ID'
- 'KO_DOCKER_REPO=us.gcr.io/$PROJECT_ID'
# write the newly created container image path to a file for use in another step
args:
- -c
- |
echo $(/ko publish ./cmd/ping --tags pr-$_PR_NUMBER,pr-$_PR_NUMBER-$SHORT_SHA) > ./image.txt || exit 1
script: /ko build ./cmd/ping --tags pr-$_PR_NUMBER,pr-$_PR_NUMBER-$SHORT_SHA > image.txt
automapSubstitutions: true

# prefetch the cloud-sdk builder
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
Expand All @@ -63,6 +69,7 @@ steps:
--image=$(cat ./image.txt) \
--region=us-central1 \
--labels="env=pr-${_PR_NUMBER}"
waitFor: ['cloud-sdk-prefetch', 'ko-build']

- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
id: run-iam-allUsers
Expand All @@ -88,3 +95,4 @@ steps:
- |
terraform -chdir=tools/terraform plan \
-var image=$(cat ./image.txt)
waitFor: ['terraform-init', 'ko-build']