Skip to content

Commit 30762f1

Browse files
committed
static: add compose
Signed-off-by: CrazyMax <[email protected]>
1 parent 097a8a3 commit 30762f1

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

static/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ 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)
67

78
ENGINE_GITCOMMIT?=$(shell cd $(realpath $(CURDIR)/../src/github.com/docker/docker) && git rev-parse --short HEAD)
89
GEN_STATIC_VER=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION))
@@ -17,6 +18,7 @@ RUNC_VERSION?=$(shell grep "ARG RUNC_VERSION" "$(ENGINE_DIR)/Dockerfile" | awk -
1718
export CLI_DIR
1819
export ENGINE_DIR
1920
export BUILDX_DIR
21+
export COMPOSE_DIR
2022
export GEN_STATIC_VER
2123
export CONTAINERD_VERSION
2224
export RUNC_VERSION
@@ -25,8 +27,8 @@ export REF
2527
export DOCKER_CLI_REF
2628
export DOCKER_ENGINE_REF
2729
export DOCKER_SCAN_REF
28-
export DOCKER_COMPOSE_REF
2930
export DOCKER_BUILDX_REF
31+
export DOCKER_COMPOSE_REF
3032

3133
export GO_VERSION
3234

static/build-static

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,19 @@ build_buildx() {
125125
)
126126
}
127127

128+
build_compose() {
129+
(
130+
cd "${COMPOSE_DIR}"
131+
set -x
132+
docker buildx build \
133+
--platform "${TARGETPLATFORM}" \
134+
--build-arg BUILDKIT_MULTI_PLATFORM=true \
135+
--build-arg GO_VERSION \
136+
--output ./bin \
137+
--target binary .
138+
)
139+
}
140+
128141
echo "TARGETPLATFORM=${TARGETPLATFORM}"
129142
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"
130143
echo "RUNC_VERSION=${RUNC_VERSION}"
@@ -142,26 +155,31 @@ dockerBuildDir="${buildDir}/docker"
142155
containerdBuildDir="${buildDir}/containerd"
143156
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
144157
buildxBuildDir="${buildDir}/docker-buildx"
158+
composeBuildDir="${buildDir}/docker-compose"
145159

146160
# clean up previous build output dirs
147161
[ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build"
148162
[ -d "${ENGINE_DIR:?}/build" ] && rm -r "${ENGINE_DIR:?}/build"
149163
[ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin"
164+
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"
150165

151166
case ${TARGETOS} in
152167
linux)
153168
build_cli
154169
build_engine
155170
build_buildx
171+
build_compose
156172
;;
157173
darwin)
158174
build_cli
159175
build_buildx
176+
build_compose
160177
;;
161178
windows)
162179
build_cli
163180
build_engine
164181
build_buildx
182+
build_compose
165183
;;
166184
esac
167185

@@ -322,6 +340,35 @@ if [ -d "${BUILDX_DIR}/bin" ]; then
322340
esac
323341
fi
324342

343+
# compose
344+
if [ -d "${COMPOSE_DIR}/bin" ]; then
345+
mkdir -p "${composeBuildDir}"
346+
case ${TARGETOS} in
347+
linux | darwin)
348+
cp "${COMPOSE_DIR}/bin/${targetPair}/docker-compose" "${composeBuildDir}/docker-compose"
349+
;;
350+
windows)
351+
cp "${COMPOSE_DIR}/bin/${targetPair}/docker-compose.exe" "${composeBuildDir}/docker-compose.exe"
352+
;;
353+
esac
354+
# package compose
355+
case ${TARGETOS} in
356+
linux | darwin)
357+
(
358+
set -x
359+
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.tgz" docker-compose
360+
)
361+
;;
362+
windows)
363+
(
364+
cd "${buildDir}"
365+
set -x
366+
zip -r "docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.zip" docker-compose
367+
)
368+
;;
369+
esac
370+
fi
371+
325372
# create bundle
326373
(
327374
# bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz

0 commit comments

Comments
 (0)