Skip to content

Commit 80d7de6

Browse files
committed
static: use moby/moby#43529
Signed-off-by: CrazyMax <[email protected]>
1 parent 5d01132 commit 80d7de6

File tree

3 files changed

+23
-49
lines changed

3 files changed

+23
-49
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
-
5353
name: Checkout
5454
uses: actions/checkout@v3
55+
-
56+
name: Set up QEMU
57+
uses: docker/setup-qemu-action@v2
5558
-
5659
name: Set up Docker Buildx
5760
uses: docker/setup-buildx-action@v1

common.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ VERSION?=0.0.1-dev
2525
# DOCKER_CLI_REPO and DOCKER_ENGINE_REPO define the source repositories to clone
2626
# the source from. These can be overridden to build from a fork.
2727
DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
28-
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
28+
#DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
29+
DOCKER_ENGINE_REPO ?= https://github.com/crazy-max/moby.git
2930
DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git
3031
DOCKER_COMPOSE_REPO ?= https://github.com/docker/compose.git
3132
DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
@@ -38,7 +39,8 @@ DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
3839
# For other situations, specify DOCKER_CLI_REF and/or DOCKER_ENGINE_REF separately.
3940
REF ?= HEAD
4041
DOCKER_CLI_REF ?= $(REF)
41-
DOCKER_ENGINE_REF ?= $(REF)
42+
#DOCKER_ENGINE_REF ?= $(REF)
43+
DOCKER_ENGINE_REF ?= cross
4244
DOCKER_SCAN_REF ?= v0.17.0
4345
DOCKER_COMPOSE_REF ?= v2.6.1
4446
DOCKER_BUILDX_REF ?= v0.8.2

static/build-static

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,19 @@ build_cli() {
4343
build_engine() {
4444
(
4545
cd "${ENGINE_DIR}"
46-
mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged
4746
set -x
4847
docker buildx build \
48+
--build-arg BUILDKIT_MULTI_PLATFORM=true \
49+
--build-arg DOCKER_LINKMODE=static \
4950
--build-arg CONTAINERD_VERSION \
5051
--build-arg DEFAULT_PRODUCT_LICENSE \
5152
--build-arg PACKAGER_NAME \
5253
--build-arg PLATFORM \
5354
--build-arg PRODUCT \
54-
--build-arg RUNC_VERSION \
5555
--build-arg VERSION="${STATIC_VERSION}" \
56-
--output ./bundles \
56+
--output ./build \
5757
--platform "${TARGETPLATFORM}" \
58-
--target binary .
59-
mkdir -p ./bundles/"${TARGETPLATFORM}"
60-
cp -r ./bundles/binary-daemon/* "./bundles/${TARGETPLATFORM}/"
61-
)
62-
}
63-
64-
build_engine_cross() {
65-
(
66-
cd "${ENGINE_DIR}"
67-
mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged
68-
set -x
69-
docker buildx build \
70-
--build-arg CONTAINERD_VERSION \
71-
--build-arg CROSS=true \
72-
--build-arg DEFAULT_PRODUCT_LICENSE \
73-
--build-arg DOCKER_CROSSPLATFORMS="${TARGETPLATFORM}" \
74-
--build-arg PACKAGER_NAME \
75-
--build-arg PLATFORM \
76-
--build-arg PRODUCT \
77-
--build-arg RUNC_VERSION \
78-
--build-arg VERSION="${STATIC_VERSION}" \
79-
--output ./bundles \
80-
--target cross .
81-
mkdir -p "./bundles/${TARGETPLATFORM}"
82-
cp ./bundles/cross/"${TARGETPLATFORM}"-daemon/* "./bundles/${TARGETPLATFORM}/"
58+
--target all .
8359
)
8460
}
8561

@@ -113,14 +89,8 @@ build_scan() {
11389
)
11490
}
11591

116-
CROSS=true
117-
if [ "$(xx-info march)" = "$(uname -m)" ] && [ "$(xx-info os)" = "linux" ]; then
118-
CROSS=false
119-
fi
120-
12192
xx-info env
12293
echo "TARGETPLATFORM=${TARGETPLATFORM}"
123-
echo "CROSS=${CROSS}"
12494
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"
12595

12696
targetPair="$(xx-info os)_$(xx-info arch)"
@@ -140,7 +110,7 @@ scanBuildDir="${buildDir}/docker-scan"
140110

141111
# clean up previous build output dirs
142112
[ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build"
143-
[ -d "${ENGINE_DIR:?}/bundles" ] && rm -r "${ENGINE_DIR:?}/bundles"
113+
[ -d "${ENGINE_DIR:?}/build" ] && rm -r "${ENGINE_DIR:?}/build"
144114
[ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin"
145115
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"
146116
[ -d "${SCAN_DIR:?}/dist" ] && rm -r "${SCAN_DIR:?}/dist"
@@ -151,11 +121,7 @@ docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx crea
151121
case $(xx-info os) in
152122
linux)
153123
build_cli
154-
if [ "$CROSS" = "false" ]; then
155-
build_engine
156-
else
157-
build_engine_cross
158-
fi
124+
build_engine
159125
build_buildx
160126
build_compose
161127
# TODO change once we support scan-plugin on other architectures
@@ -171,7 +137,7 @@ case $(xx-info os) in
171137
;;
172138
windows)
173139
build_cli
174-
build_engine_cross
140+
build_engine
175141
build_buildx
176142
build_compose
177143
# TODO change once we support scan-plugin on other architectures
@@ -216,21 +182,24 @@ mkdir -p "${dockerBuildDir}"
216182
case $(xx-info os) in
217183
linux)
218184
for f in dockerd docker-init docker-proxy; do
219-
if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then
220-
cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${dockerBuildDir}/$f"
185+
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
186+
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${dockerBuildDir}/$f"
221187
fi
222188
done
223189
# TODO containerd binaries should be built as part of containerd-packaging, not as part of docker/docker-ce-packaging
224190
mkdir -p "${containerdBuildDir}"
225191
for f in containerd ctr containerd-shim containerd-shim-runc-v2 runc; do
226-
if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then
227-
cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${containerdBuildDir}/$f"
192+
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
193+
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${containerdBuildDir}/$f"
228194
fi
229195
done
230196
;;
231197
windows)
232-
cp "${ENGINE_DIR}"/bundles/"${TARGETPLATFORM}"/dockerd-*.exe "${dockerBuildDir}/dockerd.exe"
233-
cp "${ENGINE_DIR}"/bundles/"${TARGETPLATFORM}"/docker-proxy-*.exe "${dockerBuildDir}/docker-proxy.exe"
198+
for f in dockerd.exe docker-proxy.exe; do
199+
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
200+
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${dockerBuildDir}/$f"
201+
fi
202+
done
234203
;;
235204
esac
236205
# package docker, containerd, and runc

0 commit comments

Comments
 (0)