diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03e81047f7..7b343baa11 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: pull_request: jobs: - build: + pkg: runs-on: ubuntu-20.04 strategy: fail-fast: false @@ -29,3 +29,28 @@ jobs: name: Build run: | make ${{ matrix.target }} + + static: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + target: + - linux/amd64 + - linux/arm/v6 + - linux/arm/v7 + - linux/arm64 + - darwin/amd64 + - darwin/arm64 + - windows/amd64 + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + run: | + make static-${{ matrix.target }} diff --git a/Jenkinsfile b/Jenkinsfile index cc85204979..68f4bd0dba 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,5 @@ #!groovy -def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME - def pkgs = [ [target: "centos-7", image: "centos:7", arches: ["amd64", "aarch64"]], // (EOL: June 30, 2024) [target: "centos-8", image: "quay.io/centos/centos:stream8", arches: ["amd64", "aarch64"]], @@ -19,15 +17,16 @@ def pkgs = [ [target: "ubuntu-jammy", image: "ubuntu:jammy", arches: ["amd64", "aarch64", "armhf"]], // Ubuntu 22.04 LTS (End of support: April, 2027. EOL: April, 2032) ] -def genBuildStep(LinkedHashMap pkg, String arch) { +def statics = [ + [os: "linux", arches: ["amd64", "armv6", "armv7", "aarch64"]], + [os: "darwin", arches: ["amd64", "aarch64"]], + [os: "windows", arches: ["amd64"]], +] + +def genPkgStep(LinkedHashMap pkg, String arch) { def nodeLabel = "linux&&${arch}" - def platform = "" def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME - if (arch == 'armhf') { - // Running armhf builds on EC2 requires --platform parameter - // Otherwise it accidentally pulls armel images which then breaks the verify step - platform = "--platform=linux/${arch}" nodeLabel = "${nodeLabel}&&ubuntu" } else { nodeLabel = "${nodeLabel}&&ubuntu-2004" @@ -42,6 +41,7 @@ def genBuildStep(LinkedHashMap pkg, String arch) { stage("info") { sh 'docker version' sh 'docker info' + sh 'env|sort' } stage("build") { try { @@ -55,52 +55,27 @@ def genBuildStep(LinkedHashMap pkg, String arch) { } } -def build_package_steps = [ - 'static-linux': { -> - wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) { - stage("static-linux") { - // This is just a "dummy" stage to make the distro/arch visible - // in Jenkins' BlueOcean view, which truncates names.... - sh 'echo starting...' - } - stage("info") { - sh 'docker version' - sh 'docker info' - } - stage("build") { - try { - checkout scm - sh "make REF=$branch DOCKER_BUILD_PKGS='static-linux' static" - } finally { - sh "make clean" - } - } - } - }, - 'cross-mac': { -> - wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) { - stage("cross-mac") { - // This is just a "dummy" stage to make the distro/arch visible - // in Jenkins' BlueOcean view, which truncates names.... - sh 'echo starting...' - } - stage("info") { - sh 'docker version' - sh 'docker info' - } - stage("build") { - try { - checkout scm - sh "make REF=$branch DOCKER_BUILD_PKGS='cross-mac' static" - } finally { - sh "make clean" - } - } - } - }, - 'cross-win': { -> - wrappedNode(label: 'ubuntu-2004 && x86_64', cleanWorkspace: true) { - stage("cross-win") { +def genPkgSteps(opts) { + return opts.arches.collectEntries { + ["${opts.image}-${it}": genPkgStep(opts, it)] + } +} + +def genStaticStep(LinkedHashMap pkg, String arch) { + def config = [ + amd64: [label: "x86_64", targetarch: "amd64"], + aarch64: [label: "aarch64", targetarch: "arm64"], + armv6: [label: "armhf", targetarch: "arm/v6"], + armv7: [label: "armhf", targetarch: "arm/v7"], + ][arch] + def nodeLabel = "linux&&${config.label}" + if (config.label == 'x86_64') { + nodeLabel = "${nodeLabel}&&ubuntu" + } + def branch = env.CHANGE_TARGET ?: env.BRANCH_NAME + return { -> + wrappedNode(label: nodeLabel, cleanWorkspace: true) { + stage("static-${pkg.os}-${arch}") { // This is just a "dummy" stage to make the distro/arch visible // in Jenkins' BlueOcean view, which truncates names.... sh 'echo starting...' @@ -108,25 +83,27 @@ def build_package_steps = [ stage("info") { sh 'docker version' sh 'docker info' + sh 'env|sort' } stage("build") { try { checkout scm - sh "make REF=$branch DOCKER_BUILD_PKGS='cross-win' static" + sh "make REF=$branch static-${pkg.os}/${config.targetarch}" } finally { sh "make clean" } } } - }, -] + } +} -def genPackageSteps(opts) { +def genStaticSteps(opts) { return opts.arches.collectEntries { - ["${opts.image}-${it}": genBuildStep(opts, it)] + ["static-${opts.os}-${it}": genStaticStep(opts, it)] } } -build_package_steps << pkgs.collectEntries { genPackageSteps(it) } +def parallelStages = pkgs.collectEntries { genPkgSteps(it) } +parallelStages << statics.collectEntries { genStaticSteps(it) } -parallel(build_package_steps) +parallel(parallelStages) diff --git a/Makefile b/Makefile index 3d77c151cd..20bf6b8915 100644 --- a/Makefile +++ b/Makefile @@ -92,8 +92,12 @@ debian-% raspbian-% ubuntu-%: checkout ## build deb packages for the specified d $(MAKE) -C deb VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ .PHONY: static -static: DOCKER_BUILD_PKGS:=static-linux cross-mac cross-win cross-arm -static: checkout ## build static-compiled packages - for p in $(DOCKER_BUILD_PKGS); do \ - $(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) TARGETPLATFORM=$(TARGETPLATFORM) CONTAINERD_VERSION=$(CONTAINERD_VERSION) RUNC_VERSION=$(RUNC_VERSION) $${p}; \ - done +static: static-linux static-darwin static-windows ## build static packages + +.PHONY: static-% +static-%: checkout ## build static packages for specified os + $(MAKE) -C static VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ + +.PHONY: static-linux/% static-darwin/% static-windows/% +static-linux/% static-darwin/% static-windows/%: checkout ## build static packages for specificed os/arch + $(MAKE) -C static VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ diff --git a/static/Makefile b/static/Makefile index 8915d5cc24..fc9bbb7a94 100644 --- a/static/Makefile +++ b/static/Makefile @@ -7,26 +7,6 @@ BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx) GEN_STATIC_VER=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION)) HASH_CMD=docker run -v $(CURDIR):/sum -w /sum debian:jessie bash hash_files DIR_TO_HASH:=build/linux -DOCKER_CLI_GOLANG_IMG=golang:$(GO_VERSION) - -DOCKER_BUILD_OPTS= - -ifneq ($(strip $(CONTAINERD_VERSION)),) -# Set custom build-args to override the containerd version to build for static -# packages. The Dockerfile for 20.10 and earlier used CONTAINERD_COMMIT, later -# versions use CONTAINERD_VERSION. We can remove CONTAINERD_VERSION once 20.10.x -# reaches EOL. -DOCKER_BUILD_OPTS +=--build-arg=CONTAINERD_VERSION=$(CONTAINERD_VERSION) -DOCKER_BUILD_OPTS +=--build-arg=CONTAINERD_COMMIT=$(CONTAINERD_VERSION) -endif - -ifneq ($(strip $(RUNC_VERSION)),) -# Set custom build-args to override the runc version to build for static packages. -# The Dockerfile for 20.10 and earlier used RUNC_COMMIT, later versions use -# RUNC_VERSION. We can remove RUNC_COMMIT once 20.10.x reaches EOL. -DOCKER_BUILD_OPTS +=--build-arg=RUNC_VERSION=$(RUNC_VERSION) -DOCKER_BUILD_OPTS +=--build-arg=RUNC_COMMIT=$(RUNC_VERSION) -endif .PHONY: help help: ## show make targets @@ -36,83 +16,47 @@ help: ## show make targets clean: ## remove build artifacts [ ! -d build ] || $(CHOWN) -R $(shell id -u):$(shell id -g) build $(RM) -r build - -docker builder prune -f --filter until=24h .PHONY: static -static: static-linux cross-mac cross-win cross-arm ## create all static packages +static: static-linux static-darwin static-windows ## create common static packages .PHONY: static-linux -static-linux: static-cli static-engine static-buildx-plugin ## create tgz - mkdir -p build/linux/docker - cp $(CLI_DIR)/build/docker build/linux/docker/ - for f in dockerd containerd ctr containerd-shim containerd-shim-runc-v2 docker-init docker-proxy runc; do \ - cp -L $(ENGINE_DIR)/bundles/binary-daemon/$$f build/linux/docker/$$f; \ - done - tar -C build/linux -c -z -f build/linux/docker-$(GEN_STATIC_VER).tgz docker - - # extra binaries for running rootless - mkdir -p build/linux/docker-rootless-extras - for f in rootlesskit rootlesskit-docker-proxy dockerd-rootless.sh dockerd-rootless-setuptool.sh vpnkit; do \ - if [ -f $(ENGINE_DIR)/bundles/binary-daemon/$$f ]; then \ - cp -L $(ENGINE_DIR)/bundles/binary-daemon/$$f build/linux/docker-rootless-extras/$$f; \ - fi \ - done - tar -C build/linux -c -z -f build/linux/docker-rootless-extras-$(GEN_STATIC_VER).tgz docker-rootless-extras - - # buildx - tar -C $(BUILDX_DIR)/bin -c -z -f build/linux/docker-buildx-plugin-$(DOCKER_BUILDX_REF:v%=%).tgz docker-buildx +static-linux: static-linux/amd64 static-linux/arm64 ## create common static linux packages + +.PHONY: static-darwin +static-darwin: static-darwin/amd64 static-darwin/arm64 ## create common static darwin packages + +.PHONY: static-windows +static-windows: static-windows/amd64 ## create common static windows packages + +.PHONY: static-linux/% +static-linux/%: ## create linux static packages for the specified architecture + $(MAKE) build-static TARGETPLATFORM=linux/$* + +.PHONY: static-darwin/% +static-darwin/%: ## create darwin static packages for the specified architecture + $(MAKE) build-static TARGETPLATFORM=darwin/$* + +.PHONY: static-windows/% +static-windows/%: ## create windows static packages for the specified architecture + $(MAKE) build-static TARGETPLATFORM=windows/$* + +.PHONY: build-static +build-static: + PRODUCT="$(PRODUCT)" \ + PLATFORM="$(PLATFORM)" \ + DEFAULT_PRODUCT_LICENSE="$(DEFAULT_PRODUCT_LICENSE)" \ + PACKAGER_NAME="$(PACKAGER_NAME)" \ + CLI_DIR="$(CLI_DIR)" \ + ENGINE_DIR="$(ENGINE_DIR)" \ + BUILDX_DIR="$(BUILDX_DIR)" \ + STATIC_VER="$(GEN_STATIC_VER)" \ + DOCKER_BUILDX_REF="$(DOCKER_BUILDX_REF)" \ + CONTAINERD_VERSION="$(CONTAINERD_VERSION)" \ + RUNC_VERSION="$(RUNC_VERSION)" \ + ./build-static "$(CURDIR)" "$(TARGETPLATFORM)" .PHONY: hash_files hash_files: @echo "Hashing directory $(DIR_TO_HASH)" $(HASH_CMD) "$(DIR_TO_HASH)" - -.PHONY: buildx -buildx: - docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use - -.PHONY: cross-mac -cross-mac: buildx - cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=darwin/amd64,darwin/arm64 binary - dest=$$PWD/build/mac; cd $(CLI_DIR)/build && for platform in *; do \ - arch=$$(echo $$platform | cut -d_ -f2); \ - mkdir -p $$dest/$$arch/docker; \ - cp $$platform/docker-darwin-* $$dest/$$arch/docker/docker && \ - tar -C $$dest/$$arch -c -z -f $$dest/$$arch/docker-$(GEN_STATIC_VER).tgz docker; \ - done - -.PHONY: cross-win -cross-win: cross-win-engine - cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=windows/amd64 binary - mkdir -p build/win/amd64/docker - cp $(CLI_DIR)/build/docker-windows-amd64.exe build/win/amd64/docker/docker.exe - cp $(ENGINE_DIR)/bundles/cross/windows/amd64-daemon/dockerd-$(GEN_STATIC_VER).exe build/win/amd64/docker/dockerd.exe - cp $(ENGINE_DIR)/bundles/cross/windows/amd64-daemon/docker-proxy-$(GEN_STATIC_VER).exe build/win/amd64/docker/docker-proxy.exe - docker run --rm -v $(CURDIR)/build/win/amd64:/v -w /v alpine sh -c 'apk update&&apk add zip&&zip -r docker-$(GEN_STATIC_VER).zip docker' - $(CHOWN) -R $(shell id -u):$(shell id -g) build - -.PHONY: cross-arm -cross-arm: cross-all-cli ## create tgz with linux armhf client only - mkdir -p build/arm/docker - cp $(CLI_DIR)/build/docker-linux-arm build/arm/docker/docker - tar -C build/arm -c -z -f build/arm/docker-$(GEN_STATIC_VER).tgz docker - -.PHONY: static-cli -static-cli: - cd $(CLI_DIR) && VERSION=$(GEN_STATIC_VER) docker buildx bake --set binary.platform=$(TARGETPLATFORM) --set binary.args.CGO_ENABLED=$(CGO_ENABLED) binary - -.PHONY: static-engine -static-engine: - $(MAKE) -C $(ENGINE_DIR) VERSION=$(GEN_STATIC_VER) DOCKER_BUILD_OPTS="$(DOCKER_BUILD_OPTS)" binary - -.PHONY: static-buildx-plugin -static-buildx-plugin: - cd $(BUILDX_DIR) && docker buildx bake --set binaries.platform=$(TARGETPLATFORM) binaries && mv ./bin/buildx ./bin/docker-buildx - -.PHONY: cross-all-cli -cross-all-cli: - $(MAKE) -C $(CLI_DIR) -f docker.Makefile VERSION=$(GEN_STATIC_VER) cross - -.PHONY: cross-win-engine -cross-win-engine: - $(MAKE) -C $(ENGINE_DIR) VERSION=$(GEN_STATIC_VER) DOCKER_CROSSPLATFORMS=windows/amd64 DOCKER_BUILD_OPTS="$(DOCKER_BUILD_OPTS)" cross diff --git a/static/build-static b/static/build-static new file mode 100755 index 0000000000..64b5e06099 --- /dev/null +++ b/static/build-static @@ -0,0 +1,327 @@ +#!/usr/bin/env bash +set -e + +CURDIR="$1" +TARGETPLATFORM="$2" + +: "${TARGETPLATFORM=}" +: "${TARGETOS=}" +: "${TARGETARCH=}" +: "${TARGETVARIANT=}" + +: "${CURARCH=}" +: "${CURVARIANT=}" + +if [ -z "$CURDIR" ] || [ -z "$TARGETPLATFORM" ]; then + # shellcheck disable=SC2016 + echo 'usage: ./build-static ${CURDIR} ${TARGETPLATFORM}' + exit 1 +fi + +build_cli() { + [ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build" + ( + cd "${CLI_DIR}" + set -x + docker buildx build \ + --platform "${TARGETPLATFORM}" \ + --build-arg "BUILDKIT_MULTI_PLATFORM=true" \ + --build-arg "PRODUCT=${PRODUCT}" \ + --build-arg "PLATFORM=${PLATFORM}" \ + --build-arg "DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE}" \ + --build-arg "PACKAGER_NAME=${PACKAGER_NAME}" \ + --build-arg "VERSION=${STATIC_VER}" \ + --build-arg "CGO_ENABLED=${cgo_enabled}" \ + --output "./build" \ + --target binary . + ) +} + +build_engine() { + [ -d "${ENGINE_DIR:?}/bundles" ] && rm -r "${ENGINE_DIR:?}/bundles" + ( + cd "${ENGINE_DIR}" + mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged + set -x + docker buildx build \ + --build-arg "PRODUCT=${PRODUCT}" \ + --build-arg "PLATFORM=${PLATFORM}" \ + --build-arg "DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE}" \ + --build-arg "PACKAGER_NAME=${PACKAGER_NAME}" \ + --build-arg "VERSION=${STATIC_VER}" \ + --build-arg "CONTAINERD_VERSION=${CONTAINERD_VERSION}" \ + --build-arg "RUNC_VERSION=${RUNC_VERSION}" \ + --build-arg "CGO_ENABLED=${cgo_enabled}" \ + --output "./bundles" \ + --target binary . + mkdir -p "./bundles/${TARGETPLATFORM}" + cp -r ./bundles/binary-daemon/* "./bundles/${TARGETPLATFORM}/" + ) +} + +build_engine_cross() { + [ -d "${ENGINE_DIR:?}/bundles" ] && rm -r "${ENGINE_DIR:?}/bundles" + ( + cd "${ENGINE_DIR}" + mkdir -p autogen # FIXME: remove when https://github.com/moby/moby/pull/43431 merged + set -x + docker buildx build \ + --build-arg "PRODUCT=${PRODUCT}" \ + --build-arg "PLATFORM=${PLATFORM}" \ + --build-arg "DEFAULT_PRODUCT_LICENSE=${DEFAULT_PRODUCT_LICENSE}" \ + --build-arg "PACKAGER_NAME=${PACKAGER_NAME}" \ + --build-arg "CROSS=true" \ + --build-arg "DOCKER_CROSSPLATFORMS=${TARGETPLATFORM}" \ + --build-arg "VERSION=${STATIC_VER}" \ + --build-arg "CONTAINERD_VERSION=${CONTAINERD_VERSION}" \ + --build-arg "RUNC_VERSION=${RUNC_VERSION}" \ + --build-arg "CGO_ENABLED=${cgo_enabled}" \ + --output "./bundles" \ + --target cross . + mkdir -p "./bundles/${TARGETPLATFORM}" + cp ./bundles/cross/${TARGETPLATFORM}-daemon/* "./bundles/${TARGETPLATFORM}/" + ) +} + +build_buildx() { + [ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin" + ( + cd "${BUILDX_DIR}" + set -x + docker buildx build \ + --platform "${TARGETPLATFORM}" \ + --build-arg "BUILDKIT_MULTI_PLATFORM=true" \ + --output "./bin" \ + --target binaries . + ) +} + +create_builder() { + docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use +} + +# get TARGETOS/TARGETARCH/TARGETVARIANT from TARGETPLATFORM +if [ -n "$TARGETPLATFORM" ]; then + os="$(echo $TARGETPLATFORM | cut -d"/" -f1)" + arch="$(echo $TARGETPLATFORM | cut -d"/" -f2)" + if [ -n "$os" ] && [ -n "$arch" ]; then + TARGETOS="$os" + TARGETARCH="$arch" + case "$arch" in + "arm") + case "$(echo $TARGETPLATFORM | cut -d"/" -f3)" in + "v5") + TARGETVARIANT="v5" + ;; + "v6") + TARGETVARIANT="v6" + ;; + "v8") + TARGETVARIANT="v8" + ;; + *) + TARGETVARIANT="v7" + ;; + esac + ;; + "mips"*) + TARGETVARIANT="$(echo $TARGETPLATFORM | cut -d"/" -f3)" + ;; + esac + fi +fi + +# current arch/variant +case "$(uname -m)" in + "x86_64") + CURARCH="amd64" + ;; + "i386") + CURARCH="386" + ;; + "aarch64") + CURARCH="arm64" + ;; + "arm64") + CURARCH="arm64" + ;; + "armv7l") + CURARCH="arm" + CURVARIANT="v7" + ;; + "armv6l") + CURARCH="arm" + CURVARIANT="v6" + ;; + "armv5l") + CURARCH="arm" + CURVARIANT="v5" + ;; + "riscv64") + CURARCH="riscv64" + ;; + "ppc64le") + CURARCH="ppc64le" + ;; + "s390x") + CURARCH="s390x" + ;; + "mips") + CURARCH="mips" + ;; + "mipsle") + CURARCH="mipsle" + ;; + "mips64") + CURARCH="mips64" + ;; + "mips64le") + CURARCH="mips64le" + ;; +esac + +# use current arch if empty +if [ -z "$TARGETARCH" ]; then + TARGETOS="linux" + TARGETARCH="$CURARCH" + TARGETPLATFORM="$TARGETOS/$TARGETARCH" + if [ -n "$CURVARIANT" ]; then + TARGETVARIANT="$CURVARIANT" + TARGETPLATFORM="$TARGETPLATFORM/$TARGETVARIANT" + fi +fi + +cgo_enabled="" +if [ "$TARGETARCH" = "arm" ] && [ -n "$TARGETVARIANT" ]; then + cgo_enabled="0" +fi + +targetPair="${TARGETOS}_${TARGETARCH}" +if [ -n "$TARGETVARIANT" ]; then + targetPair="${targetPair}_${TARGETVARIANT}" +fi + +buildDir="${CURDIR}/build/${TARGETOS}/${TARGETARCH}${TARGETVARIANT}" + +dockerBuildDir="${buildDir}/docker" +rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras" +buildxBuildDir="${buildDir}/docker-buildx" + +case ${TARGETOS} in + darwin|windows) + create_builder + ;; +esac + +case ${TARGETOS} in + linux) + build_cli + if [ "$TARGETARCH" = "$CURARCH" ]; then + build_engine + else + build_engine_cross + fi + build_buildx + ;; + darwin) + build_cli + build_buildx + ;; + windows) + build_cli + build_engine_cross + build_buildx +esac + +# cleanup +[ -d "${buildDir}" ] && rm -r "${buildDir}" + +# docker +mkdir -p "${dockerBuildDir}" +case ${TARGETOS} in + linux|darwin) + cp ${CLI_DIR}/build/${targetPair}/docker-${TARGETOS}-* "${dockerBuildDir}/docker" + ;; + windows) + cp ${CLI_DIR}/build/${targetPair}/docker-${TARGETOS}-*.exe "${dockerBuildDir}/docker.exe" + ;; +esac +case ${TARGETOS} in + linux) + for f in dockerd containerd ctr containerd-shim containerd-shim-runc-v2 docker-init docker-proxy runc; do + if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then + cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${dockerBuildDir}/$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 +case ${TARGETOS} in + linux|darwin) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-${STATIC_VER}.tgz" docker + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-${STATIC_VER}.zip" docker + ) + ;; +esac + +# rootless extras +case ${TARGETOS} in + linux) + for f in rootlesskit rootlesskit-docker-proxy dockerd-rootless.sh dockerd-rootless-setuptool.sh vpnkit; do + if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then + mkdir -p "${rootlessExtrasBuildDir}" + cp -L "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" "${rootlessExtrasBuildDir}/$f" + fi + done + ;; +esac +# package rootless extras +if [ -d "${rootlessExtrasBuildDir}" ]; then + case ${TARGETOS} in + linux) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-rootless-extras-${STATIC_VER}.tgz" docker-rootless-extras + ) + ;; + esac +fi + +# buildx +mkdir -p "${buildxBuildDir}" +case ${TARGETOS} in + linux|darwin) + cp "${BUILDX_DIR}/bin/${targetPair}/buildx" "${buildxBuildDir}/docker-buildx" + ;; + windows) + cp "${BUILDX_DIR}/bin/${targetPair}/buildx.exe" "${buildxBuildDir}/docker-buildx.exe" + ;; +esac +# package buildx +case ${TARGETOS} in + linux|darwin) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.tar.gz" docker-buildx + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx + ) + ;; +esac