Skip to content

Commit

Permalink
static: use moby/moby#43529
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jul 6, 2022
1 parent 5d01132 commit 80d7de6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
6 changes: 4 additions & 2 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ VERSION?=0.0.1-dev
# DOCKER_CLI_REPO and DOCKER_ENGINE_REPO define the source repositories to clone
# the source from. These can be overridden to build from a fork.
DOCKER_CLI_REPO ?= https://github.com/docker/cli.git
DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
#DOCKER_ENGINE_REPO ?= https://github.com/docker/docker.git
DOCKER_ENGINE_REPO ?= https://github.com/crazy-max/moby.git
DOCKER_SCAN_REPO ?= https://github.com/docker/scan-cli-plugin.git
DOCKER_COMPOSE_REPO ?= https://github.com/docker/compose.git
DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
Expand All @@ -38,7 +39,8 @@ DOCKER_BUILDX_REPO ?= https://github.com/docker/buildx.git
# For other situations, specify DOCKER_CLI_REF and/or DOCKER_ENGINE_REF separately.
REF ?= HEAD
DOCKER_CLI_REF ?= $(REF)
DOCKER_ENGINE_REF ?= $(REF)
#DOCKER_ENGINE_REF ?= $(REF)
DOCKER_ENGINE_REF ?= cross
DOCKER_SCAN_REF ?= v0.17.0
DOCKER_COMPOSE_REF ?= v2.6.1
DOCKER_BUILDX_REF ?= v0.8.2
Expand Down
63 changes: 16 additions & 47 deletions static/build-static
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,19 @@ build_cli() {
build_engine() {
(
cd "${ENGINE_DIR}"
mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged
set -x
docker buildx build \
--build-arg BUILDKIT_MULTI_PLATFORM=true \
--build-arg DOCKER_LINKMODE=static \
--build-arg CONTAINERD_VERSION \
--build-arg DEFAULT_PRODUCT_LICENSE \
--build-arg PACKAGER_NAME \
--build-arg PLATFORM \
--build-arg PRODUCT \
--build-arg RUNC_VERSION \
--build-arg VERSION="${STATIC_VERSION}" \
--output ./bundles \
--output ./build \
--platform "${TARGETPLATFORM}" \
--target binary .
mkdir -p ./bundles/"${TARGETPLATFORM}"
cp -r ./bundles/binary-daemon/* "./bundles/${TARGETPLATFORM}/"
)
}

build_engine_cross() {
(
cd "${ENGINE_DIR}"
mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged
set -x
docker buildx build \
--build-arg CONTAINERD_VERSION \
--build-arg CROSS=true \
--build-arg DEFAULT_PRODUCT_LICENSE \
--build-arg DOCKER_CROSSPLATFORMS="${TARGETPLATFORM}" \
--build-arg PACKAGER_NAME \
--build-arg PLATFORM \
--build-arg PRODUCT \
--build-arg RUNC_VERSION \
--build-arg VERSION="${STATIC_VERSION}" \
--output ./bundles \
--target cross .
mkdir -p "./bundles/${TARGETPLATFORM}"
cp ./bundles/cross/"${TARGETPLATFORM}"-daemon/* "./bundles/${TARGETPLATFORM}/"
--target all .
)
}

Expand Down Expand Up @@ -113,14 +89,8 @@ build_scan() {
)
}

CROSS=true
if [ "$(xx-info march)" = "$(uname -m)" ] && [ "$(xx-info os)" = "linux" ]; then
CROSS=false
fi

xx-info env
echo "TARGETPLATFORM=${TARGETPLATFORM}"
echo "CROSS=${CROSS}"
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"

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

# clean up previous build output dirs
[ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build"
[ -d "${ENGINE_DIR:?}/bundles" ] && rm -r "${ENGINE_DIR:?}/bundles"
[ -d "${ENGINE_DIR:?}/build" ] && rm -r "${ENGINE_DIR:?}/build"
[ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin"
[ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin"
[ -d "${SCAN_DIR:?}/dist" ] && rm -r "${SCAN_DIR:?}/dist"
Expand All @@ -151,11 +121,7 @@ docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx crea
case $(xx-info os) in
linux)
build_cli
if [ "$CROSS" = "false" ]; then
build_engine
else
build_engine_cross
fi
build_engine
build_buildx
build_compose
# TODO change once we support scan-plugin on other architectures
Expand All @@ -171,7 +137,7 @@ case $(xx-info os) in
;;
windows)
build_cli
build_engine_cross
build_engine
build_buildx
build_compose
# TODO change once we support scan-plugin on other architectures
Expand Down Expand Up @@ -216,21 +182,24 @@ mkdir -p "${dockerBuildDir}"
case $(xx-info os) in
linux)
for f in dockerd docker-init docker-proxy; do
if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then
cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${dockerBuildDir}/$f"
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${dockerBuildDir}/$f"
fi
done
# TODO containerd binaries should be built as part of containerd-packaging, not as part of docker/docker-ce-packaging
mkdir -p "${containerdBuildDir}"
for f in containerd ctr containerd-shim containerd-shim-runc-v2 runc; do
if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then
cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${containerdBuildDir}/$f"
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${containerdBuildDir}/$f"
fi
done
;;
windows)
cp "${ENGINE_DIR}"/bundles/"${TARGETPLATFORM}"/dockerd-*.exe "${dockerBuildDir}/dockerd.exe"
cp "${ENGINE_DIR}"/bundles/"${TARGETPLATFORM}"/docker-proxy-*.exe "${dockerBuildDir}/docker-proxy.exe"
for f in dockerd.exe docker-proxy.exe; do
if [ -f "${ENGINE_DIR}/build/${targetPair}/$f" ]; then
cp -L "${ENGINE_DIR}/build/${targetPair}/$f" "${dockerBuildDir}/$f"
fi
done
;;
esac
# package docker, containerd, and runc
Expand Down

0 comments on commit 80d7de6

Please sign in to comment.