Skip to content

Commit

Permalink
static: split cli, engine, and containerd packages
Browse files Browse the repository at this point in the history
This splits the CLI, Engine, and containerd packages to allow downloading
the cli separate from the daemon, as well as (in future) allowing us to
do a containerd release without also requiring an engine release.

With this patch:

    make REF=v22.06.0-beta.0 VERSION=v22.06.0-beta.0 TARGETPLATFORM=linux/amd64 static

    static/build
    ├── bundles-ce-static-linux-x86_64.tar.gz
    └── linux
        └── amd64
            ├── containerd-1.6.4.tgz
            ├── docker-buildx-plugin-0.8.2.tgz
            ├── docker-cli-22.06.0-beta.0.tgz
            ├── docker-engine-22.06.0-beta.0.tgz
            ├── docker-compose-plugin-2.6.1.tgz
            ├── docker-rootless-extras-22.06.0-beta.0.tgz
            └── docker-scan-plugin-0.17.0.tgz

    2 directories, 8 files

    ls -lh static/build/linux/amd64/
    total 215208
    -rw-r--r--  1 sebastiaan  staff    31M Jun 29 00:21 containerd-1.6.4.tgz
    -rw-r--r--  1 sebastiaan  staff    14M Jun 29 00:21 docker-buildx-plugin-0.8.2.tgz
    -rw-r--r--  1 sebastiaan  staff   8.2M Jun 29 00:21 docker-cli-22.06.0-beta.0.tgz
    -rw-r--r--  1 sebastiaan  staff    19M Jun 29 00:21 docker-engine-22.06.0-beta.0.tgz
    -rw-r--r--  1 sebastiaan  staff   8.8M Jun 29 00:21 docker-compose-plugin-2.6.1.tgz
    -rw-r--r--  1 sebastiaan  staff    19M Jun 29 00:21 docker-rootless-extras-22.06.0-beta.0.tgz
    -rw-r--r--  1 sebastiaan  staff   4.4M Jun 29 00:21 docker-scan-plugin-0.17.0.tgz

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 4, 2022
1 parent cc73008 commit de2dd7a
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions static/build-static
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ fi

source "../scripts/target-platform"

if [ -z "$CONTAINERD_VERSION" ]; then
# Select the default version of containerd based on the docker engine source,
# which is needed for naming the produced .tgz file. We normalize the value to
# always have a "v" prefix.
# TODO containerd binaries should be built as part of containerd-packaging, not as part of docker/docker-ce-packaging
CONTAINERD_VERSION="$(awk -F'=' '$1 == "ARG CONTAINERD_VERSION" {{sub("v","")}; print "v" $2 }' "${ENGINE_DIR}/Dockerfile.windows")"
export CONTAINERD_VERSION
fi

build_cli() {
[ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build"
(
Expand Down Expand Up @@ -130,6 +139,7 @@ echo "UNAME=$(uname -m)"
echo "TARGETPLATFORM=${TARGETPLATFORM}"
echo "CURPLATFORM=${CURPLATFORM}"
echo "CROSS=${CROSS}"
echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}"

cgo_enabled=""
if [ "$TARGETARCH" = "arm" ] && [ -n "$TARGETVARIANT" ]; then
Expand All @@ -143,7 +153,9 @@ fi

buildDir="${CURDIR}/build/${TARGETPLATFORM}"

dockerBuildDir="${buildDir}/docker"
dockerCLIBuildDir="${buildDir}/docker-cli"
dockerBuildDir="${buildDir}/docker-engine"
containerdBuildDir="${buildDir}/containerd"
rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras"
buildxBuildDir="${buildDir}/docker-buildx"
composeBuildDir="${buildDir}/docker-compose"
Expand Down Expand Up @@ -188,42 +200,75 @@ esac
# cleanup
[ -d "${buildDir}" ] && rm -r "${buildDir}"

# docker
mkdir -p "${dockerBuildDir}"
# docker CLI
mkdir -p "${dockerCLIBuildDir}"
case ${TARGETOS} in
linux | darwin)
cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-* "${dockerCLIBuildDir}/docker"
;;
windows)
cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-*.exe "${dockerCLIBuildDir}/docker.exe"
;;
esac
# package docker CLI
case ${TARGETOS} in
linux | darwin)
cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-* "${dockerBuildDir}/docker"
(
set -x
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-cli-${STATIC_VERSION}.tgz" docker-cli
)
;;
windows)
cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-*.exe "${dockerBuildDir}/docker.exe"
(
cd "${buildDir}"
set -x
zip -r "docker-cli-${STATIC_VERSION}.zip" docker-cli
)
;;
esac

# docker, containerd, and runc
mkdir -p "${dockerBuildDir}"
case ${TARGETOS} in
linux)
for f in dockerd containerd ctr containerd-shim containerd-shim-runc-v2 docker-init docker-proxy runc; do
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"
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"
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"
;;
esac
# package docker
# package docker, containerd, and runc
case ${TARGETOS} in
linux | darwin)
darwin)
(
set -x
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-engine-${STATIC_VERSION}.tgz" docker-engine
)
;;
linux)
(
set -x
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-${STATIC_VERSION}.tgz" docker
tar -C "${buildDir}" -c -z -f "${buildDir}/docker-engine-${STATIC_VERSION}.tgz" docker-engine
tar -C "${buildDir}" -c -z -f "${buildDir}/containerd-${CONTAINERD_VERSION#v}.tgz" containerd
)
;;
windows)
(
cd "${buildDir}"
set -x
zip -r "docker-${STATIC_VERSION}.zip" docker
zip -r "docker-engine-${STATIC_VERSION}.zip" docker-engine
)
;;
esac
Expand Down Expand Up @@ -358,5 +403,6 @@ fi
set -x
cd "${buildDir}"
rm -r */
# bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz
tar -zvcf "${CURDIR}/build/bundles-ce-static-${TARGETOS}-${BUNDLEARCH}.tar.gz" .
)

0 comments on commit de2dd7a

Please sign in to comment.