From b4eb54527c41f2e646cf56edd35410e2739caaec Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 30 Mar 2022 01:02:05 +0200 Subject: [PATCH 01/13] script: target platform Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- scripts/target-platform | 106 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 scripts/target-platform diff --git a/scripts/target-platform b/scripts/target-platform new file mode 100644 index 0000000000..f2cdf3f0a5 --- /dev/null +++ b/scripts/target-platform @@ -0,0 +1,106 @@ +#!/usr/bin/env bash + +: "${TARGETPLATFORM=}" +: "${TARGETOS=}" +: "${TARGETARCH=}" +: "${TARGETVARIANT=}" + +# 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 +CUROS="linux" +case "$(uname -m)" in + "x86_64") + CURARCH="amd64" + ;; + "i386") + CURARCH="386" + ;; + "aarch64") + CURARCH="arm64" + ;; + "arm64") + CURARCH="arm64" + ;; + "armv8l") + CURARCH="arm" + CURVARIANT="v8" + ;; + "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 +CURPLATFORM="$CUROS/$CURARCH" +if [ -n "$CURVARIANT" ]; then + CURPLATFORM="$CURPLATFORM/$CURVARIANT" +fi + +# 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 From fbe69acf71ecb94031d49fa716fb6267acb4c25d Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Tue, 28 Jun 2022 15:54:17 +0200 Subject: [PATCH 02/13] static: fix and refactor Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- .github/workflows/ci.yml | 40 ++++++- Jenkinsfile | 101 +++++++---------- Makefile | 16 +-- common.mk | 16 +++ static/Makefile | 110 +++--------------- static/README.md | 55 +++++++++ static/build-static | 237 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 408 insertions(+), 167 deletions(-) create mode 100644 static/README.md create mode 100644 static/build-static diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 03e81047f7..87a5d8be48 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,41 @@ jobs: name: Build run: | make ${{ matrix.target }} + + static: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + platform: + - linux/amd64 + - linux/arm/v6 + - linux/arm/v7 + - linux/arm64 + - darwin/amd64 + - darwin/arm64 + - windows/amd64 + steps: + - + name: Prepare + run: | + platform=${{ matrix.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + - + name: Checkout + uses: actions/checkout@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - + name: Build + run: | + make TARGETPLATFORM=${{ matrix.platform }} static + - + name: Upload static packages + uses: actions/upload-artifact@v2 + with: + name: static-${{ env.PLATFORM_PAIR }} + path: static/build/${{ matrix.platform }}/*.* + if-no-files-found: error + retention-days: 7 diff --git a/Jenkinsfile b/Jenkinsfile index e96a994427..9672d74bad 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") { checkout scm @@ -55,52 +55,29 @@ 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: "aarch64", targetarch: "arm/v6"], + armv7: [label: "aarch64", targetarch: "arm/v7"], + ppc64le: [label: "ppc64le", targetarch: "ppc64le"], + s390x : [label: "s390x", targetarch: "s390x"], + ][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 +85,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 TARGETPLATFORM=${pkg.os}/${config.targetarch} static" } 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 80cdae1386..aa41501601 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,5 @@ include common.mk -STATIC_VERSION=$(shell static/gen-static-ver $(realpath $(CURDIR)/src/github.com/docker/docker) $(VERSION)) - # Taken from: https://www.cmcrossroads.com/article/printing-value-makefile-variable print-% : ; @echo $($*) @@ -81,22 +79,20 @@ clean: clean-src ## remove build artifacts .PHONY: deb rpm deb rpm: checkout ## build rpm/deb packages - $(MAKE) -C $@ VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ + $(MAKE) -C $@ $@ .PHONY: centos-% fedora-% rhel-% centos-% fedora-% rhel-%: checkout ## build rpm packages for the specified distro - $(MAKE) -C rpm VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ + $(MAKE) -C rpm $@ .PHONY: debian-% raspbian-% ubuntu-% debian-% raspbian-% ubuntu-%: checkout ## build deb packages for the specified distro - $(MAKE) -C deb VERSION=$(VERSION) GO_VERSION=$(GO_VERSION) $@ + $(MAKE) -C deb $@ + .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: checkout ## build static package + $(MAKE) -C static build .PHONY: verify verify: ## verify installation of packages diff --git a/common.mk b/common.mk index fd7213b294..d42dec1e97 100644 --- a/common.mk +++ b/common.mk @@ -50,7 +50,23 @@ VERIFY_PACKAGE_REPO ?= staging # Optional flags like --platform=linux/armhf VERIFY_PLATFORM ?= +# Export vars as envs export BUILDTIME export DEFAULT_PRODUCT_LICENSE export PACKAGER_NAME export PLATFORM +export VERSION +export GO_VERSION + +export DOCKER_CLI_REPO +export DOCKER_ENGINE_REPO +export DOCKER_SCAN_REPO +export DOCKER_COMPOSE_REPO +export DOCKER_BUILDX_REPO + +export REF +export DOCKER_CLI_REF +export DOCKER_ENGINE_REF +export DOCKER_SCAN_REF +export DOCKER_COMPOSE_REF +export DOCKER_BUILDX_REF diff --git a/static/Makefile b/static/Makefile index 4850d61263..f28d477b3c 100644 --- a/static/Makefile +++ b/static/Makefile @@ -4,112 +4,32 @@ CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli) ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker) BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx) -GEN_STATIC_VER=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION)) +STATIC_VERSION=$(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= +export CLI_DIR +export ENGINE_DIR +export BUILDX_DIR -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. -DOCKER_BUILD_OPTS +=--build-arg=RUNC_VERSION=$(RUNC_VERSION) -endif +export STATIC_VERSION +export CONTAINERD_VERSION +export RUNC_VERSION .PHONY: help -help: ## show make targets - @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(BOLD)$(CYAN)%-25s$(RESET)%s\n", $$1, $$2}' .PHONY: clean 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 - -.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 + @[ ! -d build ] || $(CHOWN) -R $(shell id -u):$(shell id -g) build + @$(RM) -r build - # buildx - tar -C $(BUILDX_DIR)/bin -c -z -f build/linux/docker-buildx-plugin-$(DOCKER_BUILDX_REF:v%=%).tgz docker-buildx +.PHONY: build +build: ## build static package + ./build-static "$(CURDIR)" "$(TARGETPLATFORM)" .PHONY: hash_files -hash_files: +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.exe build/win/amd64/docker/dockerd.exe - cp $(ENGINE_DIR)/bundles/cross/windows/amd64-daemon/docker-proxy.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/README.md b/static/README.md new file mode 100644 index 0000000000..1f25007cd9 --- /dev/null +++ b/static/README.md @@ -0,0 +1,55 @@ +# Building your own Docker static package + +Static packages can be built from root directory with the following syntax + +```console +make TARGETPLATFORM=${TARGETOS}/${TARGETARCH}/${TARGETVARIANT} static +``` + +Format of `TARGETOS`, `TARGETARCH`, `TARGETVARIANT` is the same as the [platform ARGs in the global scope](https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope) +for a Dockerfile like `linux/arm/v7`. + +Artifacts will be located in `build` under the following directory structure: +`build/$os/$arch/$variant/` or `build/$os/$arch/` if there is no variant being +used. + +### Building from local source + +Specify the location of the source repositories for the engine and cli when +building packages + +* `ENGINE_DIR` -> Specifies the directory where the engine code is located, eg: `$GOPATH/src/github.com/docker/docker` +* `CLI_DIR` -> Specifies the directory where the cli code is located, eg: `$GOPATH/src/github.com/docker/cli` + +```shell +make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli TARGETPLATFORM=linux/amd64 static +``` + +## Supported platforms + +Here is a list of platforms that are currently supported: + +```console +make TARGETPLATFORM=linux/amd64 static +make TARGETPLATFORM=linux/arm/v6 static +make TARGETPLATFORM=linux/arm/v7 static +make TARGETPLATFORM=linux/arm64 static +make TARGETPLATFORM=darwin/amd64 static +make TARGETPLATFORM=darwin/arm64 static +make TARGETPLATFORM=windows/amd64 static +``` + +> note: `darwin` only packages the docker cli and plugins. + +But you can test building against whatever platform you want like: + +```console +make TARGETPLATFORM=linux/riscv64 static +make TARGETPLATFORM=linux/s390x static +``` + +Or the current one matching your host if not defined: + +```console +make static +``` diff --git a/static/build-static b/static/build-static new file mode 100644 index 0000000000..9f452eba49 --- /dev/null +++ b/static/build-static @@ -0,0 +1,237 @@ +#!/usr/bin/env bash +set -e + +source "../scripts/target-platform" + +CURDIR="$1" +TARGETPLATFORM="${2:-$CURPLATFORM}" + +if [ -z "$CURDIR" ] || [ -z "$TARGETPLATFORM" ]; then + # shellcheck disable=SC2016 + echo 'usage: ./build-static ${CURDIR} ${TARGETPLATFORM}' + exit 1 +fi + +source "../scripts/target-platform" + +build_cli() { + [ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build" + ( + cd "${CLI_DIR}" + set -x + docker buildx build \ + --build-arg BUILDKIT_MULTI_PLATFORM=true \ + --build-arg CGO_ENABLED="${cgo_enabled}" \ + --build-arg DEFAULT_PRODUCT_LICENSE \ + --build-arg PACKAGER_NAME \ + --build-arg PLATFORM \ + --build-arg PRODUCT \ + --build-arg VERSION="${STATIC_VERSION}" \ + --output ./build \ + --platform "${TARGETPLATFORM}" \ + --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 CGO_ENABLED="${cgo_enabled}" \ + --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 \ + --platform "${TARGETPLATFORM}" \ + --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 CGO_ENABLED="${cgo_enabled}" \ + --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}/" + ) +} + +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 . + ) +} + +CROSS=true +if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then + CROSS=false +fi + +echo "UNAME=$(uname -m)" +echo "TARGETPLATFORM=${TARGETPLATFORM}" +echo "CURPLATFORM=${CURPLATFORM}" +echo "CROSS=${CROSS}" + +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/${TARGETPLATFORM}" + +dockerBuildDir="${buildDir}/docker" +rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras" +buildxBuildDir="${buildDir}/docker-buildx" + +# create docker-container builder +docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use + +case ${TARGETOS} in + linux) + build_cli + if [ "$CROSS" = "false" ]; 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_VERSION}.tgz" docker + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-${STATIC_VERSION}.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_VERSION}.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}.tgz" docker-buildx + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx + ) + ;; +esac From 20c71391522d464dd3a5b7cb322a65c802e28ccb Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 30 Mar 2022 22:01:17 +0200 Subject: [PATCH 03/13] static: create bundles Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- .github/workflows/ci.yml | 8 ++++++-- scripts/target-platform | 40 ++++++++++++++++++++++++++++++++++++++++ static/build-static | 8 ++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) mode change 100644 => 100755 static/build-static diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 87a5d8be48..e9edd03bf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,10 +60,14 @@ jobs: run: | make TARGETPLATFORM=${{ matrix.platform }} static - - name: Upload static packages + name: List files + run: | + tree -nh ./static/build + - + name: Upload static bundle uses: actions/upload-artifact@v2 with: name: static-${{ env.PLATFORM_PAIR }} - path: static/build/${{ matrix.platform }}/*.* + path: static/build/*.tar.gz if-no-files-found: error retention-days: 7 diff --git a/scripts/target-platform b/scripts/target-platform index f2cdf3f0a5..6f272f826d 100644 --- a/scripts/target-platform +++ b/scripts/target-platform @@ -104,3 +104,43 @@ if [ -z "$TARGETARCH" ]; then TARGETPLATFORM="$TARGETPLATFORM/$TARGETVARIANT" fi fi + +# bundle arch +case "$TARGETARCH$TARGETVARIANT" in + "amd64") + BUNDLEARCH="x86_64" + ;; + "386") + BUNDLEARCH="i386" + ;; + "arm64") + BUNDLEARCH="aarch64" + ;; + "armv7") + BUNDLEARCH="armhf" + ;; + "armv6") + BUNDLEARCH="armel" + ;; + "riscv64") + BUNDLEARCH="riscv64" + ;; + "ppc64le") + BUNDLEARCH="ppc64le" + ;; + "s390x") + BUNDLEARCH="s390x" + ;; + "mips") + BUNDLEARCH="mips" + ;; + "mipsle") + BUNDLEARCH="mipsle" + ;; + "mips64") + BUNDLEARCH="mips64" + ;; + "mips64le") + BUNDLEARCH="mips64le" + ;; +esac diff --git a/static/build-static b/static/build-static old mode 100644 new mode 100755 index 9f452eba49..72fe9e80f2 --- a/static/build-static +++ b/static/build-static @@ -235,3 +235,11 @@ case ${TARGETOS} in ) ;; esac + +# create bundle +( + set -x + cd "${buildDir}" + rm -r */ + tar -zvcf "${CURDIR}/build/bundles-ce-static-${TARGETOS}-${BUNDLEARCH}.tar.gz" . +) From ae7e7b1dc80a2e6fa5224e57aeba655639ba0b92 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Mon, 27 Jun 2022 11:58:22 +0200 Subject: [PATCH 04/13] makefile: utilities Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- Makefile | 16 ++++++++++++++-- common.mk | 17 +++++++++++++++++ scripts/checkout.sh | 10 ++++++---- static/Makefile | 8 +++++--- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index aa41501601..0fa231f5e7 100644 --- a/Makefile +++ b/Makefile @@ -9,63 +9,75 @@ help: ## show make targets .PHONY: clean-src clean-src: - [ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src - $(RM) -r src + @[ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src + @$(RM) -r src .PHONY: src src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/buildx src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source ifdef CLI_DIR src/github.com/docker/cli: + $(call title,Copying $(CLI_DIR)) mkdir -p "$(@D)" cp -r "$(CLI_DIR)" $@ else src/github.com/docker/cli: + $(call title,Init $(DOCKER_CLI_REPO)) git init $@ git -C $@ remote add origin "$(DOCKER_CLI_REPO)" endif ifdef ENGINE_DIR src/github.com/docker/docker: + $(call title,Copying $(ENGINE_DIR)) mkdir -p "$(@D)" cp -r "$(ENGINE_DIR)" $@ else src/github.com/docker/docker: + $(call title,Init $(DOCKER_ENGINE_REPO)) git init $@ git -C $@ remote add origin "$(DOCKER_ENGINE_REPO)" endif src/github.com/docker/buildx: + $(call title,Init $(DOCKER_BUILDX_REPO)) git init $@ git -C $@ remote add origin "$(DOCKER_BUILDX_REPO)" src/github.com/docker/compose: + $(call title,Init $(DOCKER_COMPOSE_REPO)) git init $@ git -C $@ remote add origin "$(DOCKER_COMPOSE_REPO)" src/github.com/docker/scan-cli-plugin: + $(call title,Init $(DOCKER_SCAN_REPO)) git init $@ git -C $@ remote add origin "$(DOCKER_SCAN_REPO)" .PHONY: checkout-cli checkout-cli: src/github.com/docker/cli + $(call title,Checkout $(DOCKER_CLI_REPO)#$(DOCKER_CLI_REF)) ./scripts/checkout.sh src/github.com/docker/cli "$(DOCKER_CLI_REF)" .PHONY: checkout-docker checkout-docker: src/github.com/docker/docker + $(call title,Checkout $(DOCKER_ENGINE_REPO)#$(DOCKER_ENGINE_REF)) ./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)" .PHONY: checkout-buildx checkout-buildx: src/github.com/docker/buildx + $(call title,Checkout $(DOCKER_BUILDX_REPO)#$(DOCKER_BUILDX_REF)) ./scripts/checkout.sh src/github.com/docker/buildx "$(DOCKER_BUILDX_REF)" .PHONY: checkout-compose checkout-compose: src/github.com/docker/compose + $(call title,Checkout $(DOCKER_COMPOSE_REPO)#$(DOCKER_COMPOSE_REF)) ./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)" .PHONY: checkout-scan-cli-plugin checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin + $(call title,Checkout $(DOCKER_SCAN_REPO)#$(DOCKER_SCAN_REF)) ./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)" .PHONY: checkout diff --git a/common.mk b/common.mk index d42dec1e97..0f74380240 100644 --- a/common.mk +++ b/common.mk @@ -70,3 +70,20 @@ export DOCKER_ENGINE_REF export DOCKER_SCAN_REF export DOCKER_COMPOSE_REF export DOCKER_BUILDX_REF + +# utilities +BOLD := $(shell tput -T linux bold) +RED := $(shell tput -T linux setaf 1) +GREEN := $(shell tput -T linux setaf 2) +YELLOW := $(shell tput -T linux setaf 3) +BLUE := $(shell tput -T linux setaf 4) +PURPLE := $(shell tput -T linux setaf 5) +CYAN := $(shell tput -T linux setaf 6) + +RESET := $(shell tput -T linux sgr0) +TITLE := $(BOLD)$(YELLOW) +SUCCESS := $(BOLD)$(GREEN) + +define title + @printf '$(TITLE)$(1)$(RESET)\n' +endef diff --git a/scripts/checkout.sh b/scripts/checkout.sh index 6bc18479dd..c5a6ef7ae8 100755 --- a/scripts/checkout.sh +++ b/scripts/checkout.sh @@ -15,7 +15,7 @@ # limitations under the License. checkout() ( - set -ex + set -e SRC="$1" REF="$2" REF_FETCH="$REF" @@ -27,11 +27,13 @@ checkout() ( else REF="FETCH_HEAD" fi - git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH" - git -C "$SRC" checkout -q "$REF" + ( + set -x + git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH" + git -C "$SRC" checkout -q "$REF" + ) ) - # Only execute checkout function above if this file is executed, not sourced from another script prog=checkout.sh # needs to be in sync with this file's name if [ "$(basename -- $0)" = "$prog" ]; then diff --git a/static/Makefile b/static/Makefile index f28d477b3c..5f7add7ee0 100644 --- a/static/Makefile +++ b/static/Makefile @@ -17,19 +17,21 @@ export CONTAINERD_VERSION export RUNC_VERSION .PHONY: help -help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(BOLD)$(CYAN)%-25s$(RESET)%s\n", $$1, $$2}' +help: ## show make targets + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) .PHONY: clean clean: ## remove build artifacts + $(call title,Removing build artifacts) @[ ! -d build ] || $(CHOWN) -R $(shell id -u):$(shell id -g) build @$(RM) -r build .PHONY: build build: ## build static package + $(call title,Building static package for $(TARGETPLATFORM)) ./build-static "$(CURDIR)" "$(TARGETPLATFORM)" .PHONY: hash_files hash_files: ## hash files - @echo "Hashing directory $(DIR_TO_HASH)" + $(call title,Hashing directory $(DIR_TO_HASH)) $(HASH_CMD) "$(DIR_TO_HASH)" From 9b45ba19d24cbaae166645099ac72c8b80917812 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 29 Jun 2022 18:05:17 +0200 Subject: [PATCH 05/13] static: add compose and scan cli plugins Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- static/Makefile | 4 ++ static/build-static | 159 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 138 insertions(+), 25 deletions(-) diff --git a/static/Makefile b/static/Makefile index 5f7add7ee0..b3ae22fe2d 100644 --- a/static/Makefile +++ b/static/Makefile @@ -3,6 +3,8 @@ include ../common.mk CLI_DIR=$(realpath $(CURDIR)/../src/github.com/docker/cli) ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker) BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx) +COMPOSE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/compose) +SCAN_DIR=$(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) STATIC_VERSION=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION)) HASH_CMD=docker run -v $(CURDIR):/sum -w /sum debian:jessie bash hash_files @@ -11,6 +13,8 @@ DIR_TO_HASH:=build/linux export CLI_DIR export ENGINE_DIR export BUILDX_DIR +export COMPOSE_DIR +export SCAN_DIR export STATIC_VERSION export CONTAINERD_VERSION diff --git a/static/build-static b/static/build-static index 72fe9e80f2..73ec454dc4 100755 --- a/static/build-static +++ b/static/build-static @@ -93,6 +93,26 @@ build_buildx() { ) } +build_compose() { + [ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin" + ( + cd "${COMPOSE_DIR}" + set -x + # TODO: Add TARGETPLATFORM support on compose repo to build efficiently with buildx + make GIT_TAG="${DOCKER_COMPOSE_REF}" cross + ) +} + +build_scan() { + [ -d "${SCAN_DIR:?}/bin" ] && rm -r "${SCAN_DIR:?}/bin" + ( + cd "${SCAN_DIR}" + set -x + # TODO: Add TARGETPLATFORM support on scan-cli-plugin repo to build efficiently with --platform + make GIT_TAG_NAME="${DOCKER_SCAN_REF}" cross + ) +} + CROSS=true if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then CROSS=false @@ -118,6 +138,8 @@ buildDir="${CURDIR}/build/${TARGETPLATFORM}" dockerBuildDir="${buildDir}/docker" rootlessExtrasBuildDir="${buildDir}/docker-rootless-extras" buildxBuildDir="${buildDir}/docker-buildx" +composeBuildDir="${buildDir}/docker-compose" +scanBuildDir="${buildDir}/docker-scan" # create docker-container builder docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use @@ -131,15 +153,27 @@ case ${TARGETOS} in build_engine_cross fi build_buildx + build_compose + # TODO change once we support scan-plugin on other architectures + if [ "${TARGETARCH}" = "amd64" ]; then + build_scan + fi ;; darwin) build_cli build_buildx + build_compose + build_scan ;; windows) build_cli build_engine_cross build_buildx + build_compose + # TODO change once we support scan-plugin on other architectures + if [ "${TARGETARCH}" = "amd64" ]; then + build_scan + fi ;; esac @@ -210,31 +244,106 @@ if [ -d "${rootlessExtrasBuildDir}" ]; then 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}.tgz" docker-buildx - ) - ;; - windows) - ( - cd "${buildDir}" - set -x - zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx - ) - ;; -esac +if [ -d "${BUILDX_DIR}/bin" ]; then + 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}.tgz" docker-buildx + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-buildx-plugin-${DOCKER_BUILDX_REF#v}.zip" docker-buildx + ) + ;; + esac +fi + +# compose +if [ -d "${COMPOSE_DIR}/bin" ]; then + mkdir -p "${composeBuildDir}" + composeTargetPair="${TARGETOS}" + case ${TARGETARCH} in + amd64) + composeTargetPair="${composeTargetPair}-x86_64" + ;; + arm64) + composeTargetPair="${composeTargetPair}-aarch64" + ;; + *) + composeTargetPair="${composeTargetPair}-${TARGETARCH}" + ;; + esac + if [ -n "$TARGETVARIANT" ]; then + composeTargetPair="${composeTargetPair}${TARGETVARIANT}" + fi + case ${TARGETOS} in + linux | darwin) + cp "${COMPOSE_DIR}/bin/docker-compose-${composeTargetPair}" "${composeBuildDir}/docker-compose" + ;; + windows) + cp "${COMPOSE_DIR}/bin/docker-compose-${composeTargetPair}.exe" "${composeBuildDir}/docker-compose.exe" + ;; + esac + # package compose + case ${TARGETOS} in + linux | darwin) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.tgz" docker-compose + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-compose-plugin-${DOCKER_COMPOSE_REF#v}.zip" docker-compose + ) + ;; + esac +fi + +# scan +if [ -d "${SCAN_DIR}/dist" ]; then + mkdir -p "${scanBuildDir}" + case ${TARGETOS} in + linux | darwin) + cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}" "${scanBuildDir}/docker-scan" + ;; + windows) + cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}.exe" "${scanBuildDir}/docker-scan.exe" + ;; + esac + # package compose + case ${TARGETOS} in + linux | darwin) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-scan-plugin-${DOCKER_SCAN_REF#v}.tgz" docker-scan + ) + ;; + windows) + ( + cd "${buildDir}" + set -x + zip -r "docker-scan-plugin-${DOCKER_SCAN_REF#v}.zip" docker-scan + ) + ;; + esac +fi # create bundle ( From f672549ad4586db297eb78c8e6c734428c71ab56 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 29 Jun 2022 18:07:14 +0200 Subject: [PATCH 06/13] static: shfmt Signed-off-by: CrazyMax Signed-off-by: Sebastiaan van Stijn --- static/hash_files | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/hash_files b/static/hash_files index 6218d977a5..e2feda7911 100644 --- a/static/hash_files +++ b/static/hash_files @@ -6,6 +6,6 @@ DIR_TO_LOOK_IN=${1:-build/linux} for f in $(find "$DIR_TO_LOOK_IN" -type f); do for hash_algo in md5 sha256; do - "${hash_algo}sum" "$f" >"$f.$hash_algo" + "${hash_algo}sum" "$f" > "$f.$hash_algo" done done From b2050096f55b7b7df381e6692e1c3b621651d018 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Jun 2022 12:06:15 +0200 Subject: [PATCH 07/13] static: split cli, engine, and containerd packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Sebastiaan van Stijn --- static/Makefile | 6 +++++ static/build-static | 57 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/static/Makefile b/static/Makefile index b3ae22fe2d..12facc5db8 100644 --- a/static/Makefile +++ b/static/Makefile @@ -17,6 +17,12 @@ export COMPOSE_DIR export SCAN_DIR export STATIC_VERSION + +# Select the default version of containerd based on the docker engine source +# we need this variable here for naming the produced .tgz file. +# TODO containerd binaries should be built as part of containerd-packaging, not as part of docker/docker-ce-packaging +CONTAINERD_VERSION?=v$(shell grep "ARG CONTAINERD_VERSION" "$(ENGINE_DIR)/Dockerfile.windows" | awk -F'=' '{print $$2}') + export CONTAINERD_VERSION export RUNC_VERSION diff --git a/static/build-static b/static/build-static index 73ec454dc4..332b006b46 100755 --- a/static/build-static +++ b/static/build-static @@ -122,6 +122,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 @@ -135,7 +136,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" @@ -180,42 +183,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}"-* "${dockerBuildDir}/docker" + cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-* "${dockerCLIBuildDir}/docker" ;; windows) - cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-*.exe "${dockerBuildDir}/docker.exe" + cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-*.exe "${dockerCLIBuildDir}/docker.exe" + ;; +esac +# package docker CLI +case ${TARGETOS} in + linux | darwin) + ( + set -x + tar -C "${buildDir}" -c -z -f "${buildDir}/docker-cli-${STATIC_VERSION}.tgz" docker-cli + ) + ;; + windows) + ( + 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 @@ -350,5 +386,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" . ) From 025dbb5ce0f857164a246d74183f4194358cbef6 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 29 Jun 2022 23:19:21 +0200 Subject: [PATCH 08/13] static: remove target_platform and switch to xx Signed-off-by: CrazyMax --- Makefile | 12 +++- common.mk | 4 ++ scripts/target-platform | 146 ---------------------------------------- static/Makefile | 2 + static/build-static | 106 +++++++++++++++-------------- 5 files changed, 70 insertions(+), 200 deletions(-) delete mode 100644 scripts/target-platform diff --git a/Makefile b/Makefile index 0fa231f5e7..aab971117c 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,10 @@ src/github.com/docker/scan-cli-plugin: git init $@ git -C $@ remote add origin "$(DOCKER_SCAN_REPO)" +src/github.com/tonistiigi/xx: + $(call title,Init $(XX_REPO)) + git init $@ + git -C $@ remote add origin "$(XX_REPO)" .PHONY: checkout-cli checkout-cli: src/github.com/docker/cli @@ -83,6 +87,11 @@ checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin .PHONY: checkout checkout: checkout-cli checkout-docker checkout-buildx checkout-compose checkout-scan-cli-plugin ## checkout source at the given reference(s) +.PHONY: checkout-xx +checkout-xx: src/github.com/tonistiigi/xx + $(call title,Checkout $(XX_REPO)#$(XX_REF)) + ./scripts/checkout.sh src/github.com/tonistiigi/xx "$(XX_REF)" + .PHONY: clean clean: clean-src ## remove build artifacts $(MAKE) -C rpm clean @@ -101,9 +110,8 @@ centos-% fedora-% rhel-%: checkout ## build rpm packages for the specified distr debian-% raspbian-% ubuntu-%: checkout ## build deb packages for the specified distro $(MAKE) -C deb $@ - .PHONY: static -static: checkout ## build static package +static: checkout checkout-xx ## build static package $(MAKE) -C static build .PHONY: verify diff --git a/common.mk b/common.mk index 0f74380240..1efa453716 100644 --- a/common.mk +++ b/common.mk @@ -43,6 +43,10 @@ DOCKER_SCAN_REF ?= v0.17.0 DOCKER_COMPOSE_REF ?= v2.6.1 DOCKER_BUILDX_REF ?= v0.8.2 +# XX is used as cross-compilation helper for static bundles +XX_REPO ?= https://github.com/tonistiigi/xx.git +XX_REF ?= v1.1.1 + # Use "stage" to install dependencies from download-stage.docker.com during the # verify step. Leave empty or use any other value to install from download.docker.com VERIFY_PACKAGE_REPO ?= staging diff --git a/scripts/target-platform b/scripts/target-platform deleted file mode 100644 index 6f272f826d..0000000000 --- a/scripts/target-platform +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash - -: "${TARGETPLATFORM=}" -: "${TARGETOS=}" -: "${TARGETARCH=}" -: "${TARGETVARIANT=}" - -# 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 -CUROS="linux" -case "$(uname -m)" in - "x86_64") - CURARCH="amd64" - ;; - "i386") - CURARCH="386" - ;; - "aarch64") - CURARCH="arm64" - ;; - "arm64") - CURARCH="arm64" - ;; - "armv8l") - CURARCH="arm" - CURVARIANT="v8" - ;; - "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 -CURPLATFORM="$CUROS/$CURARCH" -if [ -n "$CURVARIANT" ]; then - CURPLATFORM="$CURPLATFORM/$CURVARIANT" -fi - -# 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 - -# bundle arch -case "$TARGETARCH$TARGETVARIANT" in - "amd64") - BUNDLEARCH="x86_64" - ;; - "386") - BUNDLEARCH="i386" - ;; - "arm64") - BUNDLEARCH="aarch64" - ;; - "armv7") - BUNDLEARCH="armhf" - ;; - "armv6") - BUNDLEARCH="armel" - ;; - "riscv64") - BUNDLEARCH="riscv64" - ;; - "ppc64le") - BUNDLEARCH="ppc64le" - ;; - "s390x") - BUNDLEARCH="s390x" - ;; - "mips") - BUNDLEARCH="mips" - ;; - "mipsle") - BUNDLEARCH="mipsle" - ;; - "mips64") - BUNDLEARCH="mips64" - ;; - "mips64le") - BUNDLEARCH="mips64le" - ;; -esac diff --git a/static/Makefile b/static/Makefile index 12facc5db8..80460e536c 100644 --- a/static/Makefile +++ b/static/Makefile @@ -5,6 +5,7 @@ ENGINE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/docker) BUILDX_DIR=$(realpath $(CURDIR)/../src/github.com/docker/buildx) COMPOSE_DIR=$(realpath $(CURDIR)/../src/github.com/docker/compose) SCAN_DIR=$(realpath $(CURDIR)/../src/github.com/docker/scan-cli-plugin) +XX_DIR=$(realpath $(CURDIR)/../src/github.com/tonistiigi/xx) STATIC_VERSION=$(shell ./gen-static-ver $(CLI_DIR) $(VERSION)) HASH_CMD=docker run -v $(CURDIR):/sum -w /sum debian:jessie bash hash_files @@ -15,6 +16,7 @@ export ENGINE_DIR export BUILDX_DIR export COMPOSE_DIR export SCAN_DIR +export XX_DIR export STATIC_VERSION diff --git a/static/build-static b/static/build-static index 332b006b46..e11641ae6f 100755 --- a/static/build-static +++ b/static/build-static @@ -1,27 +1,34 @@ #!/usr/bin/env bash set -e -source "../scripts/target-platform" +function xx-info() { + "$XX_DIR"/base/xx-info "$1" +} CURDIR="$1" -TARGETPLATFORM="${2:-$CURPLATFORM}" - -if [ -z "$CURDIR" ] || [ -z "$TARGETPLATFORM" ]; then +if [ -z "$CURDIR" ]; then # shellcheck disable=SC2016 - echo 'usage: ./build-static ${CURDIR} ${TARGETPLATFORM}' + echo 'CURDIR is required. See README.md for usage.' exit 1 fi -source "../scripts/target-platform" +TARGETPLATFORM="$2" +if [ -z "$TARGETPLATFORM" ]; then + TARGETPLATFORM="$(xx-info os)/$(xx-info arch)" + if [ -n "$(xx-info variant)" ]; then + TARGETPLATFORM="$TARGETPLATFORM/$(xx-info variant)" + fi +fi +# TARGETPLATFORM is also used by xx-info +export TARGETPLATFORM build_cli() { - [ -d "${CLI_DIR:?}/build" ] && rm -r "${CLI_DIR:?}/build" ( cd "${CLI_DIR}" set -x docker buildx build \ --build-arg BUILDKIT_MULTI_PLATFORM=true \ - --build-arg CGO_ENABLED="${cgo_enabled}" \ + --build-arg GO_LINKMODE=static \ --build-arg DEFAULT_PRODUCT_LICENSE \ --build-arg PACKAGER_NAME \ --build-arg PLATFORM \ @@ -34,13 +41,11 @@ build_cli() { } 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 CGO_ENABLED="${cgo_enabled}" \ --build-arg CONTAINERD_VERSION \ --build-arg DEFAULT_PRODUCT_LICENSE \ --build-arg PACKAGER_NAME \ @@ -57,13 +62,11 @@ build_engine() { } 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 CGO_ENABLED="${cgo_enabled}" \ --build-arg CONTAINERD_VERSION \ --build-arg CROSS=true \ --build-arg DEFAULT_PRODUCT_LICENSE \ @@ -81,7 +84,6 @@ build_engine_cross() { } build_buildx() { - [ -d "${BUILDX_DIR:?}/bin" ] && rm -r "${BUILDX_DIR:?}/bin" ( cd "${BUILDX_DIR}" set -x @@ -94,7 +96,6 @@ build_buildx() { } build_compose() { - [ -d "${COMPOSE_DIR:?}/bin" ] && rm -r "${COMPOSE_DIR:?}/bin" ( cd "${COMPOSE_DIR}" set -x @@ -104,7 +105,6 @@ build_compose() { } build_scan() { - [ -d "${SCAN_DIR:?}/bin" ] && rm -r "${SCAN_DIR:?}/bin" ( cd "${SCAN_DIR}" set -x @@ -114,24 +114,18 @@ build_scan() { } CROSS=true -if [ "$TARGETOS" = "linux" ] && [ "$CURARCH$CURVARIANT" = "$TARGETARCH$TARGETVARIANT" ]; then +if [ "$(xx-info march)" = "$(uname -m)" ] && [ "$(xx-info os)" = "linux" ]; then CROSS=false fi -echo "UNAME=$(uname -m)" +xx-info env echo "TARGETPLATFORM=${TARGETPLATFORM}" -echo "CURPLATFORM=${CURPLATFORM}" echo "CROSS=${CROSS}" echo "CONTAINERD_VERSION=${CONTAINERD_VERSION}" -cgo_enabled="" -if [ "$TARGETARCH" = "arm" ] && [ -n "$TARGETVARIANT" ]; then - cgo_enabled="0" -fi - -targetPair="${TARGETOS}_${TARGETARCH}" -if [ -n "$TARGETVARIANT" ]; then - targetPair="${targetPair}_${TARGETVARIANT}" +targetPair="$(xx-info os)_$(xx-info arch)" +if [ -n "$(xx-info variant)" ]; then + targetPair="${targetPair}_$(xx-info variant)" fi buildDir="${CURDIR}/build/${TARGETPLATFORM}" @@ -144,10 +138,17 @@ buildxBuildDir="${buildDir}/docker-buildx" composeBuildDir="${buildDir}/docker-compose" 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 "${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" + # create docker-container builder docker buildx inspect | grep -q 'Driver: docker-container' || docker buildx create --use -case ${TARGETOS} in +case $(xx-info os) in linux) build_cli if [ "$CROSS" = "false" ]; then @@ -158,7 +159,7 @@ case ${TARGETOS} in build_buildx build_compose # TODO change once we support scan-plugin on other architectures - if [ "${TARGETARCH}" = "amd64" ]; then + if [ "$(xx-info arch)" = "amd64" ]; then build_scan fi ;; @@ -174,7 +175,7 @@ case ${TARGETOS} in build_buildx build_compose # TODO change once we support scan-plugin on other architectures - if [ "${TARGETARCH}" = "amd64" ]; then + if [ "$(xx-info arch)" = "amd64" ]; then build_scan fi ;; @@ -185,16 +186,16 @@ esac # docker CLI mkdir -p "${dockerCLIBuildDir}" -case ${TARGETOS} in +case $(xx-info os) in linux | darwin) - cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-* "${dockerCLIBuildDir}/docker" + cp "${CLI_DIR}"/build/"${targetPair}"/docker-"$(xx-info os)"-* "${dockerCLIBuildDir}/docker" ;; windows) - cp "${CLI_DIR}"/build/"${targetPair}"/docker-"${TARGETOS}"-*.exe "${dockerCLIBuildDir}/docker.exe" + cp "${CLI_DIR}"/build/"${targetPair}"/docker-"$(xx-info os)"-*.exe "${dockerCLIBuildDir}/docker.exe" ;; esac # package docker CLI -case ${TARGETOS} in +case $(xx-info os) in linux | darwin) ( set -x @@ -212,7 +213,7 @@ esac # docker, containerd, and runc mkdir -p "${dockerBuildDir}" -case ${TARGETOS} in +case $(xx-info os) in linux) for f in dockerd docker-init docker-proxy; do if [ -f "${ENGINE_DIR}/bundles/${TARGETPLATFORM}/$f" ]; then @@ -233,7 +234,7 @@ case ${TARGETOS} in ;; esac # package docker, containerd, and runc -case ${TARGETOS} in +case $(xx-info os) in darwin) ( set -x @@ -257,7 +258,7 @@ case ${TARGETOS} in esac # rootless extras -case ${TARGETOS} in +case $(xx-info os) 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 @@ -269,7 +270,7 @@ case ${TARGETOS} in esac # package rootless extras if [ -d "${rootlessExtrasBuildDir}" ]; then - case ${TARGETOS} in + case $(xx-info os) in linux) ( set -x @@ -282,7 +283,7 @@ fi # buildx if [ -d "${BUILDX_DIR}/bin" ]; then mkdir -p "${buildxBuildDir}" - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) cp "${BUILDX_DIR}/bin/${targetPair}/buildx" "${buildxBuildDir}/docker-buildx" ;; @@ -291,7 +292,7 @@ if [ -d "${BUILDX_DIR}/bin" ]; then ;; esac # package buildx - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) ( set -x @@ -311,8 +312,8 @@ fi # compose if [ -d "${COMPOSE_DIR}/bin" ]; then mkdir -p "${composeBuildDir}" - composeTargetPair="${TARGETOS}" - case ${TARGETARCH} in + composeTargetPair="$(xx-info os)" + case $(xx-info arch) in amd64) composeTargetPair="${composeTargetPair}-x86_64" ;; @@ -320,13 +321,13 @@ if [ -d "${COMPOSE_DIR}/bin" ]; then composeTargetPair="${composeTargetPair}-aarch64" ;; *) - composeTargetPair="${composeTargetPair}-${TARGETARCH}" + composeTargetPair="${composeTargetPair}-$(xx-info arch)" ;; esac - if [ -n "$TARGETVARIANT" ]; then - composeTargetPair="${composeTargetPair}${TARGETVARIANT}" + if [ -n "$(xx-info variant)" ]; then + composeTargetPair="${composeTargetPair}$(xx-info variant)" fi - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) cp "${COMPOSE_DIR}/bin/docker-compose-${composeTargetPair}" "${composeBuildDir}/docker-compose" ;; @@ -335,7 +336,7 @@ if [ -d "${COMPOSE_DIR}/bin" ]; then ;; esac # package compose - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) ( set -x @@ -355,16 +356,16 @@ fi # scan if [ -d "${SCAN_DIR}/dist" ]; then mkdir -p "${scanBuildDir}" - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) - cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}" "${scanBuildDir}/docker-scan" + cp "${SCAN_DIR}/dist/docker-scan_$(xx-info os)_$(xx-info arch)" "${scanBuildDir}/docker-scan" ;; windows) - cp "${SCAN_DIR}/dist/docker-scan_${TARGETOS}_${TARGETARCH}.exe" "${scanBuildDir}/docker-scan.exe" + cp "${SCAN_DIR}/dist/docker-scan_$(xx-info os)_$(xx-info arch).exe" "${scanBuildDir}/docker-scan.exe" ;; esac # package compose - case ${TARGETOS} in + case $(xx-info os) in linux | darwin) ( set -x @@ -383,9 +384,10 @@ fi # create bundle ( + # bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz + bundlesFilename="bundles-ce-static-$(xx-info os)-$(xx-info arch)$(xx-info variant).tar.gz" 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" . + tar -zvcf "${CURDIR}/build/${bundlesFilename}" . ) From d69a81e8f9a21156426dd0defe33db37fb97e4df Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 6 Jul 2022 14:59:09 +0200 Subject: [PATCH 09/13] static: use moby/moby pr 43529 Signed-off-by: CrazyMax --- .github/workflows/ci.yml | 3 ++ common.mk | 6 ++-- static/build-static | 63 ++++++++++------------------------------ 3 files changed, 23 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9edd03bf3..cd6c8e740c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/common.mk b/common.mk index 1efa453716..42c91049ce 100644 --- a/common.mk +++ b/common.mk @@ -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 @@ -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 diff --git a/static/build-static b/static/build-static index e11641ae6f..7e547c6a3b 100755 --- a/static/build-static +++ b/static/build-static @@ -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 . ) } @@ -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)" @@ -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" @@ -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 @@ -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 @@ -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 From b7683d484acb753b3378f911a3a55b78c929ba73 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 20 Jul 2022 08:35:19 +0200 Subject: [PATCH 10/13] ci: add more pkgs to matrix Signed-off-by: CrazyMax --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd6c8e740c..d785d26f78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,9 @@ jobs: matrix: target: - debian-bullseye + - ubuntu-jammy + - centos-7 + - fedora-36 steps: - name: Checkout From c7893a10405367c384563943d58d038276c122d0 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 20 Jul 2022 09:41:48 +0200 Subject: [PATCH 11/13] pkg: fix docker daemon build path and output folder Signed-off-by: CrazyMax --- deb/common/rules | 12 ++++++------ rpm/SPECS/docker-ce.spec | 8 ++++---- rpm/centos-7/Dockerfile | 1 - rpm/centos-8/Dockerfile | 1 - rpm/centos-9/Dockerfile | 1 - rpm/fedora-34/Dockerfile | 1 - rpm/fedora-35/Dockerfile | 1 - rpm/fedora-36/Dockerfile | 1 - rpm/rhel-7/Dockerfile | 1 - 9 files changed, 10 insertions(+), 17 deletions(-) diff --git a/deb/common/rules b/deb/common/rules index 9b495e9388..90e7e02e74 100755 --- a/deb/common/rules +++ b/deb/common/rules @@ -10,9 +10,9 @@ override_dh_builddeb: override_dh_auto_build: # Build the daemon and dependencies - cd engine && DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary - cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini - cd engine && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic + cd /go/src/github.com/docker/docker && DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary + cd /go/src/github.com/docker/docker && TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini + cd /go/src/github.com/docker/docker && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic # Build the CLI cd /go/src/github.com/docker/cli && VERSION=$(VERSION) GITCOMMIT=$(CLI_GITCOMMIT) LDFLAGS='' GO_LINKMODE=dynamic ./scripts/build/binary && DISABLE_WARN_OUTSIDE_CONTAINER=1 LDFLAGS='' make manpages @@ -40,7 +40,7 @@ override_dh_auto_build: fi override_dh_auto_test: - ver="$$(engine/bundles/dynbinary-daemon/dockerd --version)"; \ + ver="$$(engine/bundles/dynbinary/dockerd --version)"; \ test "$$ver" = "Docker version $(VERSION), build $(ENGINE_GITCOMMIT)" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($$ver) did not match" && exit 1) ver="$$(cli/build/docker --version)"; \ @@ -71,8 +71,8 @@ override_dh_auto_install: # docker-ce install install -D -m 0644 engine/contrib/init/systemd/docker.service debian/docker-ce/lib/systemd/system/docker.service install -D -m 0644 engine/contrib/init/systemd/docker.socket debian/docker-ce/lib/systemd/system/docker.socket - install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/dockerd) debian/docker-ce/usr/bin/dockerd - install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary-daemon/docker-proxy) debian/docker-ce/usr/bin/docker-proxy + install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary/dockerd) debian/docker-ce/usr/bin/dockerd + install -D -m 0755 $(shell readlink -e engine/bundles/dynbinary/docker-proxy) debian/docker-ce/usr/bin/docker-proxy install -D -m 0755 /usr/local/bin/docker-init debian/docker-ce/usr/bin/docker-init # docker-buildx-plugin install diff --git a/rpm/SPECS/docker-ce.spec b/rpm/SPECS/docker-ce.spec index 6352f7b1bb..3265631283 100644 --- a/rpm/SPECS/docker-ce.spec +++ b/rpm/SPECS/docker-ce.spec @@ -84,18 +84,18 @@ export DOCKER_GITCOMMIT=%{_gitcommit_engine} mkdir -p /go/src/github.com/docker ln -snf ${RPM_BUILD_DIR}/src/engine /go/src/github.com/docker/docker -pushd ${RPM_BUILD_DIR}/src/engine +pushd /go/src/github.com/docker/docker TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini VERSION=%{_origversion} PRODUCT=docker hack/make.sh dynbinary popd %check -ver="$(engine/bundles/dynbinary-daemon/dockerd --version)"; \ +ver="$(engine/bundles/dynbinary/dockerd --version)"; \ test "$ver" = "Docker version %{_origversion}, build %{_gitcommit_engine}" && echo "PASS: daemon version OK" || (echo "FAIL: daemon version ($ver) did not match" && exit 1) %install -install -D -p -m 0755 $(readlink -f engine/bundles/dynbinary-daemon/dockerd) ${RPM_BUILD_ROOT}%{_bindir}/dockerd -install -D -p -m 0755 $(readlink -f engine/bundles/dynbinary-daemon/docker-proxy) ${RPM_BUILD_ROOT}%{_bindir}/docker-proxy +install -D -p -m 0755 $(readlink -f engine/bundles/dynbinary/dockerd) ${RPM_BUILD_ROOT}%{_bindir}/dockerd +install -D -p -m 0755 $(readlink -f engine/bundles/dynbinary/docker-proxy) ${RPM_BUILD_ROOT}%{_bindir}/docker-proxy install -D -p -m 0755 /usr/local/bin/docker-init ${RPM_BUILD_ROOT}%{_bindir}/docker-init # install systemd scripts diff --git a/rpm/centos-7/Dockerfile b/rpm/centos-7/Dockerfile index 8ab5b0c882..e5cec7e24f 100644 --- a/rpm/centos-7/Dockerfile +++ b/rpm/centos-7/Dockerfile @@ -15,7 +15,6 @@ ENV GOPROXY=https://proxy.golang.org ENV GO111MODULE=off ENV GOPATH=/go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ARG DISTRO ARG SUITE ENV DISTRO=${DISTRO} diff --git a/rpm/centos-8/Dockerfile b/rpm/centos-8/Dockerfile index a85c697853..c1a1ad79b4 100644 --- a/rpm/centos-8/Dockerfile +++ b/rpm/centos-8/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH=/go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ENV DOCKER_BUILDTAGS exclude_graphdriver_btrfs ARG DISTRO ARG SUITE diff --git a/rpm/centos-9/Dockerfile b/rpm/centos-9/Dockerfile index d8ac71442e..3a9c121ff7 100644 --- a/rpm/centos-9/Dockerfile +++ b/rpm/centos-9/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH=/go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ENV DOCKER_BUILDTAGS exclude_graphdriver_btrfs ARG DISTRO ARG SUITE diff --git a/rpm/fedora-34/Dockerfile b/rpm/fedora-34/Dockerfile index 688cc0a370..58c9e80ad3 100644 --- a/rpm/fedora-34/Dockerfile +++ b/rpm/fedora-34/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH /go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ARG DISTRO ARG SUITE ENV DISTRO=${DISTRO} diff --git a/rpm/fedora-35/Dockerfile b/rpm/fedora-35/Dockerfile index d1b3f7f055..f04fccaafe 100644 --- a/rpm/fedora-35/Dockerfile +++ b/rpm/fedora-35/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH /go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ARG DISTRO ARG SUITE ENV DISTRO=${DISTRO} diff --git a/rpm/fedora-36/Dockerfile b/rpm/fedora-36/Dockerfile index 023c3a8ecb..d19098c0e4 100644 --- a/rpm/fedora-36/Dockerfile +++ b/rpm/fedora-36/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH /go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ARG DISTRO ARG SUITE ENV DISTRO=${DISTRO} diff --git a/rpm/rhel-7/Dockerfile b/rpm/rhel-7/Dockerfile index bc487dbce1..e38633b5c5 100644 --- a/rpm/rhel-7/Dockerfile +++ b/rpm/rhel-7/Dockerfile @@ -10,7 +10,6 @@ ENV GOPROXY=direct ENV GO111MODULE=off ENV GOPATH=/go ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin -ENV AUTO_GOPATH 1 ARG DISTRO ARG SUITE ENV DISTRO=${DISTRO} From 32d34b5b61e39b5480472f1cebea1d8f546d9418 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 20 Jul 2022 09:53:19 +0200 Subject: [PATCH 12/13] pkg: use GITCOMMIT Signed-off-by: CrazyMax --- common.mk | 2 +- deb/common/rules | 2 +- rpm/SPECS/docker-ce-rootless-extras.spec | 2 +- rpm/SPECS/docker-ce.spec | 2 +- rpm/gen-rpm-ver | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common.mk b/common.mk index 42c91049ce..4377fb3e56 100644 --- a/common.mk +++ b/common.mk @@ -16,7 +16,7 @@ BUILDTIME=$(shell date -u -d "@$${SOURCE_DATE_EPOCH:-$$(date +%s)}" --rfc-3339 n CHOWN:=docker run --rm -v $(CURDIR):/v -w /v alpine chown DEFAULT_PRODUCT_LICENSE:=Community Engine PACKAGER_NAME?= -DOCKER_GITCOMMIT:=abcdefg +GITCOMMIT:=abcdefg GO_VERSION:=1.18.4 PLATFORM=Docker Engine - Community SHELL:=/bin/bash diff --git a/deb/common/rules b/deb/common/rules index 90e7e02e74..cfccdd0267 100755 --- a/deb/common/rules +++ b/deb/common/rules @@ -10,7 +10,7 @@ override_dh_builddeb: override_dh_auto_build: # Build the daemon and dependencies - cd /go/src/github.com/docker/docker && DOCKER_GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary + cd /go/src/github.com/docker/docker && GITCOMMIT=$(ENGINE_GITCOMMIT) PRODUCT=docker ./hack/make.sh dynbinary cd /go/src/github.com/docker/docker && TMP_GOPATH="/go" hack/dockerfile/install/install.sh tini cd /go/src/github.com/docker/docker && TMP_GOPATH="/go" hack/dockerfile/install/install.sh rootlesskit dynamic # Build the CLI diff --git a/rpm/SPECS/docker-ce-rootless-extras.spec b/rpm/SPECS/docker-ce-rootless-extras.spec index b29c66745a..124ca55c31 100644 --- a/rpm/SPECS/docker-ce-rootless-extras.spec +++ b/rpm/SPECS/docker-ce-rootless-extras.spec @@ -36,7 +36,7 @@ Either VPNKit or slirp4netns (>= 0.4.0) needs to be installed separately. %build -export DOCKER_GITCOMMIT=%{_gitcommit_engine} +export GITCOMMIT=%{_gitcommit_engine} mkdir -p /go/src/github.com/docker ln -snf ${RPM_BUILD_DIR}/src/engine /go/src/github.com/docker/docker TMP_GOPATH="/go" ${RPM_BUILD_DIR}/src/engine/hack/dockerfile/install/install.sh rootlesskit dynamic diff --git a/rpm/SPECS/docker-ce.spec b/rpm/SPECS/docker-ce.spec index 3265631283..45128fd1a7 100644 --- a/rpm/SPECS/docker-ce.spec +++ b/rpm/SPECS/docker-ce.spec @@ -80,7 +80,7 @@ depending on a particular stack or provider. %build -export DOCKER_GITCOMMIT=%{_gitcommit_engine} +export GITCOMMIT=%{_gitcommit_engine} mkdir -p /go/src/github.com/docker ln -snf ${RPM_BUILD_DIR}/src/engine /go/src/github.com/docker/docker diff --git a/rpm/gen-rpm-ver b/rpm/gen-rpm-ver index 4c9d438085..99fe19edbd 100755 --- a/rpm/gen-rpm-ver +++ b/rpm/gen-rpm-ver @@ -73,9 +73,9 @@ rpmRelease=1 tilde='~' rpmVersion="${rpmVersion//-/$tilde}" -DOCKER_GITCOMMIT=$($GIT_COMMAND rev-parse --short HEAD) +GITCOMMIT=$($GIT_COMMAND rev-parse --short HEAD) if [ -n "$($GIT_COMMAND status --porcelain --untracked-files=no)" ]; then - DOCKER_GITCOMMIT="$DOCKER_GITCOMMIT-unsupported" + GITCOMMIT="$GITCOMMIT-unsupported" fi # if we have a "-dev" suffix or have change in Git, this is a nightly build, and @@ -112,4 +112,4 @@ fi # Replace any remaining dashes with periods rpmVersion="${rpmVersion//-/.}" -echo "$rpmVersion $rpmRelease $DOCKER_GITCOMMIT $origVersion" +echo "$rpmVersion $rpmRelease $GITCOMMIT $origVersion" From 8bdee0196d50e427675316039b2d53d799814c5f Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Wed, 20 Jul 2022 10:53:20 +0200 Subject: [PATCH 13/13] static: fix CONTAINERD_VERSION Signed-off-by: CrazyMax --- static/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/Makefile b/static/Makefile index 80460e536c..ee9e1be7a1 100644 --- a/static/Makefile +++ b/static/Makefile @@ -23,7 +23,7 @@ export STATIC_VERSION # Select the default version of containerd based on the docker engine source # we need this variable here for naming the produced .tgz file. # TODO containerd binaries should be built as part of containerd-packaging, not as part of docker/docker-ce-packaging -CONTAINERD_VERSION?=v$(shell grep "ARG CONTAINERD_VERSION" "$(ENGINE_DIR)/Dockerfile.windows" | awk -F'=' '{print $$2}') +CONTAINERD_VERSION?=$(shell grep "ARG CONTAINERD_VERSION" "$(ENGINE_DIR)/Dockerfile.windows" | awk -F'=' '{print $$2}') export CONTAINERD_VERSION export RUNC_VERSION