Skip to content

Commit 916472d

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 820dc5c commit 916472d

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
@@ -99,6 +99,26 @@ build_buildx() {
9999
)
100100
}
101101

102+
build_compose() {
103+
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"
104+
(
105+
cd "${COMPOSE_DIR}"
106+
set -x
107+
# TODO: Add TARGETPLATFORM support on compose repo to build efficiently with buildx
108+
make GIT_TAG="${DOCKER_COMPOSE_REF}" cross
109+
)
110+
}
111+
112+
build_scan() {
113+
[ -d "${SCAN_DIR:?}/bin" ] && rm -r "${SCAN_DIR:?}/bin"
114+
(
115+
cd "${SCAN_DIR}"
116+
set -x
117+
# TODO: Add TARGETPLATFORM support on scan-cli-plugin repo to build efficiently with --platform
118+
make GIT_TAG_NAME="${DOCKER_SCAN_REF}" cross
119+
)
120+
}
121+
102122
CROSS=true
103123
if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then
104124
CROSS=false
@@ -124,6 +144,8 @@ buildDir="${CURDIR}/build/${TARGETPLATFORM}"
124144
dockerBuildDir="${buildDir}/docker"
125145
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
126146
buildxBuildDir="${buildDir}/docker-buildx"
147+
composeBuildDir="${buildDir}/docker-compose"
148+
scanBuildDir="${buildDir}/docker-scan"
127149

128150
# create docker-container builder
129151
docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use
@@ -137,15 +159,27 @@ case ${TARGETOS} in
137159
build_engine_cross
138160
fi
139161
build_buildx
162+
build_compose
163+
# TODO change once we support scan-plugin on other architectures
164+
if [ "${TARGETARCH}" = "amd64" ]; then
165+
build_scan
166+
fi
140167
;;
141168
darwin)
142169
build_cli
143170
build_buildx
171+
build_compose
172+
build_scan
144173
;;
145174
windows)
146175
build_cli
147176
build_engine_cross
148177
build_buildx
178+
build_compose
179+
# TODO change once we support scan-plugin on other architectures
180+
if [ "${TARGETARCH}" = "amd64" ]; then
181+
build_scan
182+
fi
149183
;;
150184
esac
151185

@@ -216,31 +250,106 @@ if [ -d "${rootlessExtrasBuildDir}" ]; then
216250
fi
217251

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

245354
# create bundle
246355
(

0 commit comments

Comments
 (0)