Skip to content

Commit 91e2538

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 d18c75e commit 91e2538

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
@@ -101,6 +101,26 @@ build_buildx() {
101101
)
102102
}
103103

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+
104124
CROSS=true
105125
if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then
106126
CROSS=false
@@ -126,6 +146,8 @@ buildDir="${CURDIR}/build/${TARGETPLATFORM}"
126146
dockerBuildDir="${buildDir}/docker"
127147
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
128148
buildxBuildDir="${buildDir}/docker-buildx"
149+
composeBuildDir="${buildDir}/docker-compose"
150+
scanBuildDir="${buildDir}/docker-scan"
129151

130152
# create docker-container builder
131153
docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use
@@ -139,15 +161,27 @@ case ${TARGETOS} in
139161
build_engine_cross
140162
fi
141163
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
142169
;;
143170
darwin)
144171
build_cli
145172
build_buildx
173+
build_compose
174+
build_scan
146175
;;
147176
windows)
148177
build_cli
149178
build_engine_cross
150179
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
151185
;;
152186
esac
153187

@@ -218,31 +252,106 @@ if [ -d "${rootlessExtrasBuildDir}" ]; then
218252
fi
219253

220254
# 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
246355

247356
# create bundle
248357
(

0 commit comments

Comments
 (0)