Skip to content

Commit d2192e8

Browse files
crazy-maxthaJeztah
authored andcommitted
static: add compose and scan cli plugins
Signed-off-by: CrazyMax <[email protected]> Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 743563d commit d2192e8

File tree

2 files changed

+138
-25
lines changed

2 files changed

+138
-25
lines changed

static/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ include ../common.mk
33
CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli)
44
ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker)
55
BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx)
6+
COMPOSE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/compose)
7+
SCAN_DIR=$(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin)
68

79
STATIC_VERSION=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION))
810
HASH_CMD=docker run -v $(CURDIR):/sum -w /sum debian:jessie bash hash_files
@@ -11,6 +13,8 @@ DIR_TO_HASH:=build/linux
1113
export CLI_DIR
1214
export ENGINE_DIR
1315
export BUILDX_DIR
16+
export COMPOSE_DIR
17+
export SCAN_DIR
1418

1519
export STATIC_VERSION
1620
export CONTAINERD_VERSION

static/build-static

Lines changed: 134 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,26 @@ build_buildx() {
9393
)
9494
}
9595

96+
build_compose() {
97+
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"
98+
(
99+
cd "${COMPOSE_DIR}"
100+
set -x
101+
# TODO: Add TARGETPLATFORM support on compose repo to build efficiently with buildx
102+
make GIT_TAG="${DOCKER_COMPOSE_REF}" cross
103+
)
104+
}
105+
106+
build_scan() {
107+
[ -d "${SCAN_DIR:?}/bin" ] && rm -r "${SCAN_DIR:?}/bin"
108+
(
109+
cd "${SCAN_DIR}"
110+
set -x
111+
# TODO: Add TARGETPLATFORM support on scan-cli-plugin repo to build efficiently with --platform
112+
make GIT_TAG_NAME="${DOCKER_SCAN_REF}" cross
113+
)
114+
}
115+
96116
CROSS=true
97117
if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then
98118
CROSS=false
@@ -118,6 +138,8 @@ buildDir="${CURDIR}/build/${TARGETPLATFORM}"
118138
dockerBuildDir="${buildDir}/docker"
119139
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
120140
buildxBuildDir="${buildDir}/docker-buildx"
141+
composeBuildDir="${buildDir}/docker-compose"
142+
scanBuildDir="${buildDir}/docker-scan"
121143

122144
# create docker-container builder
123145
docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use
@@ -131,15 +153,27 @@ case ${TARGETOS} in
131153
build_engine_cross
132154
fi
133155
build_buildx
156+
build_compose
157+
# TODO change once we support scan-plugin on other architectures
158+
if [ "${TARGETARCH}" = "amd64" ]; then
159+
build_scan
160+
fi
134161
;;
135162
darwin)
136163
build_cli
137164
build_buildx
165+
build_compose
166+
build_scan
138167
;;
139168
windows)
140169
build_cli
141170
build_engine_cross
142171
build_buildx
172+
build_compose
173+
# TODO change once we support scan-plugin on other architectures
174+
if [ "${TARGETARCH}" = "amd64" ]; then
175+
build_scan
176+
fi
143177
;;
144178
esac
145179

@@ -210,31 +244,106 @@ if [ -d "${rootlessExtrasBuildDir}" ]; then
210244
fi
211245

212246
# buildx
213-
mkdir -p "${buildxBuildDir}"
214-
case ${TARGETOS} in
215-
linux | darwin)
216-
cp "${BUILDX_DIR}/bin/${targetPair}/buildx" "${buildxBuildDir}/docker-buildx"
217-
;;
218-
windows)
219-
cp "${BUILDX_DIR}/bin/${targetPair}/buildx.exe" "${buildxBuildDir}/docker-buildx.exe"
220-
;;
221-
esac
222-
# package buildx
223-
case ${TARGETOS} in
224-
linux | darwin)
225-
(
226-
set -x
227-
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.tgz" docker-buildx
228-
)
229-
;;
230-
windows)
231-
(
232-
cd "${buildDir}"
233-
set -x
234-
zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx
235-
)
236-
;;
237-
esac
247+
if [ -d "${BUILDX_DIR}/bin" ]; then
248+
mkdir -p "${buildxBuildDir}"
249+
case ${TARGETOS} in
250+
linux | darwin)
251+
cp "${BUILDX_DIR}/bin/${targetPair}/buildx" "${buildxBuildDir}/docker-buildx"
252+
;;
253+
windows)
254+
cp "${BUILDX_DIR}/bin/${targetPair}/buildx.exe" "${buildxBuildDir}/docker-buildx.exe"
255+
;;
256+
esac
257+
# package buildx
258+
case ${TARGETOS} in
259+
linux | darwin)
260+
(
261+
set -x
262+
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.tgz" docker-buildx
263+
)
264+
;;
265+
windows)
266+
(
267+
cd "${buildDir}"
268+
set -x
269+
zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx
270+
)
271+
;;
272+
esac
273+
fi
274+
275+
# compose
276+
if [ -d "${COMPOSE_DIR}/bin" ]; then
277+
mkdir -p "${composeBuildDir}"
278+
composeTargetPair="${TARGETOS}"
279+
case ${TARGETARCH} in
280+
amd64)
281+
composeTargetPair="${composeTargetPair}-x86_64"
282+
;;
283+
arm64)
284+
composeTargetPair="${composeTargetPair}-aarch64"
285+
;;
286+
*)
287+
composeTargetPair="${composeTargetPair}-${TARGETARCH}"
288+
;;
289+
esac
290+
if [ -n "$TARGETVARIANT" ]; then
291+
composeTargetPair="${composeTargetPair}${TARGETVARIANT}"
292+
fi
293+
case ${TARGETOS} in
294+
linux | darwin)
295+
cp "${COMPOSE_DIR}/bin/docker-compose-${composeTargetPair}" "${composeBuildDir}/docker-compose"
296+
;;
297+
windows)
298+
cp "${COMPOSE_DIR}/bin/docker-compose-${composeTargetPair}.exe" "${composeBuildDir}/docker-compose.exe"
299+
;;
300+
esac
301+
# package compose
302+
case ${TARGETOS} in
303+
linux | darwin)
304+
(
305+
set -x
306+
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.tgz" docker-compose
307+
)
308+
;;
309+
windows)
310+
(
311+
cd "${buildDir}"
312+
set -x
313+
zip -r "docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.zip" docker-compose
314+
)
315+
;;
316+
esac
317+
fi
318+
319+
# scan
320+
if [ -d "${SCAN_DIR}/dist" ]; then
321+
mkdir -p "${scanBuildDir}"
322+
case ${TARGETOS} in
323+
linux | darwin)
324+
cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}" "${scanBuildDir}/docker-scan"
325+
;;
326+
windows)
327+
cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}.exe" "${scanBuildDir}/docker-scan.exe"
328+
;;
329+
esac
330+
# package compose
331+
case ${TARGETOS} in
332+
linux | darwin)
333+
(
334+
set -x
335+
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-scan-plugin-${DOCKER_SCAN_REF#v}.tgz" docker-scan
336+
)
337+
;;
338+
windows)
339+
(
340+
cd "${buildDir}"
341+
set -x
342+
zip -r "docker-scan-plugin-${DOCKER_SCAN_REF#v}.zip" docker-scan
343+
)
344+
;;
345+
esac
346+
fi
238347

239348
# create bundle
240349
(

0 commit comments

Comments
 (0)