@@ -101,6 +101,26 @@ build_buildx() {
101
101
)
102
102
}
103
103
104
+ build_compose () {
105
+ [ -d " ${COMPOSE_DIR:? } /bin" ] && rm -r " ${COMPOSE_DIR:? } /bin"
106
+ (
107
+ cd " ${COMPOSE_DIR} "
108
+ set -x
109
+ # TODO: Add TARGETPLATFORM support on compose repo to build efficiently with buildx
110
+ make GIT_TAG=" ${DOCKER_COMPOSE_REF} " cross
111
+ )
112
+ }
113
+
114
+ build_scan () {
115
+ [ -d " ${SCAN_DIR:? } /bin" ] && rm -r " ${SCAN_DIR:? } /bin"
116
+ (
117
+ cd " ${SCAN_DIR} "
118
+ set -x
119
+ # TODO: Add TARGETPLATFORM support on scan-cli-plugin repo to build efficiently with --platform
120
+ make GIT_TAG_NAME=" ${DOCKER_SCAN_REF} " cross
121
+ )
122
+ }
123
+
104
124
CROSS=true
105
125
if [ " $TARGETOS " = " linux" ] && [ " $CURARCH$CURVARIANT " = " $TARGETARCH$TARGETVARIANT " ]; then
106
126
CROSS=false
@@ -126,6 +146,8 @@ buildDir="${CURDIR}/build/${TARGETPLATFORM}"
126
146
dockerBuildDir=" ${buildDir} /docker"
127
147
rootlessExtrasBuildDir=" ${buildDir} /docker-rootless-extras"
128
148
buildxBuildDir=" ${buildDir} /docker-buildx"
149
+ composeBuildDir=" ${buildDir} /docker-compose"
150
+ scanBuildDir=" ${buildDir} /docker-scan"
129
151
130
152
# create docker-container builder
131
153
docker buildx inspect | grep -q ' Driver: docker-container' || docker buildx create --use
@@ -139,15 +161,27 @@ case ${TARGETOS} in
139
161
build_engine_cross
140
162
fi
141
163
build_buildx
164
+ build_compose
165
+ # TODO change once we support scan-plugin on other architectures
166
+ if [ " ${TARGETARCH} " = " amd64" ]; then
167
+ build_scan
168
+ fi
142
169
;;
143
170
darwin)
144
171
build_cli
145
172
build_buildx
173
+ build_compose
174
+ build_scan
146
175
;;
147
176
windows)
148
177
build_cli
149
178
build_engine_cross
150
179
build_buildx
180
+ build_compose
181
+ # TODO change once we support scan-plugin on other architectures
182
+ if [ " ${TARGETARCH} " = " amd64" ]; then
183
+ build_scan
184
+ fi
151
185
;;
152
186
esac
153
187
@@ -218,31 +252,106 @@ if [ -d "${rootlessExtrasBuildDir}" ]; then
218
252
fi
219
253
220
254
# buildx
221
- mkdir -p " ${buildxBuildDir} "
222
- case ${TARGETOS} in
223
- linux | darwin)
224
- cp " ${BUILDX_DIR} /bin/${targetPair} /buildx" " ${buildxBuildDir} /docker-buildx"
225
- ;;
226
- windows)
227
- cp " ${BUILDX_DIR} /bin/${targetPair} /buildx.exe" " ${buildxBuildDir} /docker-buildx.exe"
228
- ;;
229
- esac
230
- # package buildx
231
- case ${TARGETOS} in
232
- linux | darwin)
233
- (
234
- set -x
235
- tar -C " ${buildDir} " -c -z -f " ${buildDir} /docker-buildx-plugin-${DOCKER_BUILDX_REF# v} .tgz" docker-buildx
236
- )
237
- ;;
238
- windows)
239
- (
240
- cd " ${buildDir} "
241
- set -x
242
- zip -r " docker-buildx-plugin-${DOCKER_BUILDX_REF# v} .zip" docker-buildx
243
- )
244
- ;;
245
- esac
255
+ if [ -d " ${BUILDX_DIR} /bin" ]; then
256
+ mkdir -p " ${buildxBuildDir} "
257
+ case ${TARGETOS} in
258
+ linux | darwin)
259
+ cp " ${BUILDX_DIR} /bin/${targetPair} /buildx" " ${buildxBuildDir} /docker-buildx"
260
+ ;;
261
+ windows)
262
+ cp " ${BUILDX_DIR} /bin/${targetPair} /buildx.exe" " ${buildxBuildDir} /docker-buildx.exe"
263
+ ;;
264
+ esac
265
+ # package buildx
266
+ case ${TARGETOS} in
267
+ linux | darwin)
268
+ (
269
+ set -x
270
+ tar -C " ${buildDir} " -c -z -f " ${buildDir} /docker-buildx-plugin-${DOCKER_BUILDX_REF# v} .tgz" docker-buildx
271
+ )
272
+ ;;
273
+ windows)
274
+ (
275
+ cd " ${buildDir} "
276
+ set -x
277
+ zip -r " docker-buildx-plugin-${DOCKER_BUILDX_REF# v} .zip" docker-buildx
278
+ )
279
+ ;;
280
+ esac
281
+ fi
282
+
283
+ # compose
284
+ if [ -d " ${COMPOSE_DIR} /bin" ]; then
285
+ mkdir -p " ${composeBuildDir} "
286
+ composeTargetPair=" ${TARGETOS} "
287
+ case ${TARGETARCH} in
288
+ amd64)
289
+ composeTargetPair=" ${composeTargetPair} -x86_64"
290
+ ;;
291
+ arm64)
292
+ composeTargetPair=" ${composeTargetPair} -aarch64"
293
+ ;;
294
+ * )
295
+ composeTargetPair=" ${composeTargetPair} -${TARGETARCH} "
296
+ ;;
297
+ esac
298
+ if [ -n " $TARGETVARIANT " ]; then
299
+ composeTargetPair=" ${composeTargetPair}${TARGETVARIANT} "
300
+ fi
301
+ case ${TARGETOS} in
302
+ linux | darwin)
303
+ cp " ${COMPOSE_DIR} /bin/docker-compose-${composeTargetPair} " " ${composeBuildDir} /docker-compose"
304
+ ;;
305
+ windows)
306
+ cp " ${COMPOSE_DIR} /bin/docker-compose-${composeTargetPair} .exe" " ${composeBuildDir} /docker-compose.exe"
307
+ ;;
308
+ esac
309
+ # package compose
310
+ case ${TARGETOS} in
311
+ linux | darwin)
312
+ (
313
+ set -x
314
+ tar -C " ${buildDir} " -c -z -f " ${buildDir} /docker-compose-plugin-${DOCKER_COMPOSE_REF# v} .tgz" docker-compose
315
+ )
316
+ ;;
317
+ windows)
318
+ (
319
+ cd " ${buildDir} "
320
+ set -x
321
+ zip -r " docker-compose-plugin-${DOCKER_COMPOSE_REF# v} .zip" docker-compose
322
+ )
323
+ ;;
324
+ esac
325
+ fi
326
+
327
+ # scan
328
+ if [ -d " ${SCAN_DIR} /dist" ]; then
329
+ mkdir -p " ${scanBuildDir} "
330
+ case ${TARGETOS} in
331
+ linux | darwin)
332
+ cp " ${SCAN_DIR} /dist/docker-scan_${TARGETOS} _${TARGETARCH} " " ${scanBuildDir} /docker-scan"
333
+ ;;
334
+ windows)
335
+ cp " ${SCAN_DIR} /dist/docker-scan_${TARGETOS} _${TARGETARCH} .exe" " ${scanBuildDir} /docker-scan.exe"
336
+ ;;
337
+ esac
338
+ # package compose
339
+ case ${TARGETOS} in
340
+ linux | darwin)
341
+ (
342
+ set -x
343
+ tar -C " ${buildDir} " -c -z -f " ${buildDir} /docker-scan-plugin-${DOCKER_SCAN_REF# v} .tgz" docker-scan
344
+ )
345
+ ;;
346
+ windows)
347
+ (
348
+ cd " ${buildDir} "
349
+ set -x
350
+ zip -r " docker-scan-plugin-${DOCKER_SCAN_REF# v} .zip" docker-scan
351
+ )
352
+ ;;
353
+ esac
354
+ fi
246
355
247
356
# create bundle
248
357
(
0 commit comments