forked from google/trillian-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild_docker.yaml
189 lines (185 loc) · 6.5 KB
/
cloudbuild_docker.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# This cloudbuild script builds docker images we expect users to
# commonly deploy, and stores these in cloud registry.
# This builds the images multi-arch so they run on x64 and Raspberry Pi.
timeout: 3600s
options:
machineType: E2_HIGHCPU_32
volumes:
- name: go-modules
path: /go
env:
- GO111MODULE=on
- GOPROXY=https://proxy.golang.org
- PROJECT_ROOT=github.com/google/trillian-examples
- GOPATH=/go
- GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore # Temporary work-around v1.proto already registered error.
- 'DOCKER_CLI_EXPERIMENTAL=enabled'
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['run', '--privileged', 'linuxkit/binfmt:v0.8']
id: 'initialize-qemu'
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'create', '--name', 'mybuilder']
id: 'create-builder'
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'use', 'mybuilder']
id: 'select-builder'
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'inspect', '--bootstrap']
id: 'show-target-build-platforms'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/witness:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/witness:latest',
'-f', './witness/golang/cmd/witness/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-witness-image'
# Write this build to a serverless log. Note that this step is experimental, and it is configured
# to always appear to succeed from the view of Cloud Build, although more details may be found in
# the logs.
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
# Set ERR trap to be inherited by shell functions. Allows our bash command logs to show up in
# Cloud Console.
- '-E'
- '-c'
- |
docker pull gcr.io/$PROJECT_ID/witness &&
# Special /workspace path:
# https://cloud.google.com/build/docs/configuring-builds/pass-data-between-steps#passing_data_using_workspaces
echo $(docker images --format '{{.Digest}}' gcr.io/$PROJECT_ID/witness) > /workspace/image-digest.txt ||
# Tell Cloud Build that this step succeeded. See this workaround documented here:
# https://github.com/GoogleCloudPlatform/cloud-builders/issues/253#issuecomment-381600420
exit 0
waitFor:
- build-witness-image
id: 'store-witness-image-digest'
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
# Set ERR trap to be inherited by shell functions. Allows our bash command logs to show up in
# Cloud Console.
- '-E'
- '-c'
- |
gcloud functions call create_gcs_object --data="{
\"bucket\":\"${_BUCKET}\",
\"entryContent\":\"${REPO_NAME},${COMMIT_SHA},$(cat /workspace/image-digest.txt),linux/amd64\",
\"entryPath\":\"${_ENTRIES_DIR}/linux-amd64-${COMMIT_SHA}\"
}" &&
gcloud functions call create_gcs_object --data="{
\"bucket\":\"${_BUCKET}\",
\"entryContent\":\"${REPO_NAME},${COMMIT_SHA},$(cat /workspace/image-digest.txt),linux/arm/v7\",
\"entryPath\":\"${_ENTRIES_DIR}/linux-arm-v7-${COMMIT_SHA}\"
}" &&
gcloud functions call sequence --data="{
\"entriesDir\": \"${_ENTRIES_DIR}\",
\"origin\": \"default\",
\"bucket\": \"${_BUCKET}\"
}" &&
gcloud functions call integrate --data="{
\"origin\": \"default\",
\"bucket\": \"${_BUCKET}\"
}" ||
# Tell Cloud Build that this step succeeded. See this workaround documented here:
# https://github.com/GoogleCloudPlatform/cloud-builders/issues/253#issuecomment-381600420
exit 0
waitFor:
- store-witness-image-digest
id: 'write-to-transparency-log'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/sumdb-feeder:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/sumdb-feeder:latest',
'-f', './sumdbaudit/witness/cmd/feeder/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-sumdb-feeder-image'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/distribute-to-github:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/distribute-to-github:latest',
'-f', './serverless/cmd/distribute/github/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-distribute-to-github-image'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/serverless-feeder:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/serverless-feeder:latest',
'-f', './serverless/cmd/feeder/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-serverless-feeder-image'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/rekor-feeder:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/rekor-feeder:latest',
'-f', './feeder/cmd/rekor_feeder/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-rekor-feeder-image'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/pixel-bt-feeder:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/pixel-bt-feeder:latest',
'-f', './feeder/cmd/pixel_bt_feeder/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-pixel-feeder-image'
- name: 'gcr.io/cloud-builders/docker'
args: [
'buildx',
'build',
'--platform', '$_DOCKER_BUILDX_PLATFORMS',
'-t', 'gcr.io/$PROJECT_ID/omniwitness-monolith:latest',
'--cache-from', 'gcr.io/$PROJECT_ID/omniwitness-monolith:latest',
'-f', './witness/golang/omniwitness/monolith/Dockerfile',
'--push',
'.'
]
waitFor:
- show-target-build-platforms
id: 'build-omniwitness-monolith-image'
substitutions:
_DOCKER_BUILDX_PLATFORMS: 'linux/amd64,linux/arm/v7'
_BUCKET: 'transparency_log'
_ENTRIES_DIR: 'log_entries'