diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc857c757b..4bddb9f3ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,20 +35,22 @@ jobs: strategy: fail-fast: false matrix: - platform: - - linux/amd64 - - linux/arm/v6 - - linux/arm/v7 - - linux/arm64 - - darwin/amd64 - - darwin/arm64 - - windows/amd64 + include: + - os: linux + arch: x86_64 + - os: linux + arch: armel + - os: linux + arch: armhf + - os: linux + arch: aarch64 + - os: darwin + arch: x86_64 + - os: darwin + arch: aarch64 + - os: windows + arch: x86_64 steps: - - - name: Prepare - run: | - platform=${{ matrix.platform }} - echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v3 @@ -58,7 +60,7 @@ jobs: - name: Build run: | - make TARGETPLATFORM=${{ matrix.platform }} static + make STATICOS=${{ matrix.os }} STATICARCH=${{ matrix.arch }} static - name: List files run: | @@ -67,7 +69,7 @@ jobs: name: Upload static bundle uses: actions/upload-artifact@v3 with: - name: static-${{ env.PLATFORM_PAIR }} + name: static-${{ matrix.os }}-${{ matrix.arch }} path: static/build/*.tar.gz if-no-files-found: error retention-days: 2 diff --git a/Jenkinsfile b/Jenkinsfile index ace954a0bf..b44811b324 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,9 +17,9 @@ def pkgs = [ ] def statics = [ - [os: "linux", arches: ["amd64", "armv6", "armv7", "aarch64"]], - [os: "darwin", arches: ["amd64", "aarch64"]], - [os: "windows", arches: ["amd64"]], + [os: "linux", arches: ["x86_64", "armel", "armhf", "aarch64"]], + [os: "darwin", arches: ["x86_64", "aarch64"]], + [os: "windows", arches: ["x86_64"]], ] def genPkgStep(LinkedHashMap pkg, String arch) { @@ -62,12 +62,12 @@ def genPkgSteps(opts) { 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"], + x86_64: [label: "x86_64"], + aarch64: [label: "aarch64"], + armel: [label: "aarch64"], + armhf: [label: "aarch64"], + ppc64le: [label: "ppc64le"], + s390x : [label: "s390x"], ][arch] def nodeLabel = "linux&&${config.label}" if (config.label == 'x86_64') { @@ -89,7 +89,7 @@ def genStaticStep(LinkedHashMap pkg, String arch) { stage("build") { try { checkout scm - sh "make REF=$branch TARGETPLATFORM=${pkg.os}/${config.targetarch} static" + sh "make REF=$branch STATICOS=${pkg.os} STATICARCH=${arch} static" } finally { sh "make clean" } diff --git a/static/Makefile b/static/Makefile index d8ca222314..21730a4bb9 100644 --- a/static/Makefile +++ b/static/Makefile @@ -45,7 +45,7 @@ create_builder: # create docker-container builder .PHONY: build build: create_builder ## build static package - CURDIR=$(CURDIR) TARGETPLATFORM=$(TARGETPLATFORM) ./build-static + CURDIR=$(CURDIR) STATICOS=$(STATICOS) STATICARCH=$(STATICARCH) ./build-static .PHONY: hash_files hash_files: ## hash files diff --git a/static/README.md b/static/README.md index 1f25007cd9..d2b3a971e7 100644 --- a/static/README.md +++ b/static/README.md @@ -3,15 +3,14 @@ Static packages can be built from root directory with the following syntax ```console -make TARGETPLATFORM=${TARGETOS}/${TARGETARCH}/${TARGETVARIANT} static +make STATICOS=${STATICOS} STATICOS=${STATICARCH} 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`. +Format of `STATICOS`, `STATICARCH` should respect the current folder structure on +[download.docker.com](https://download-stage.docker.com/linux/static/stable/) like +`STATICOS=linux STATICARCH=armhf`. -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. +Artifacts will be located in `build` under `build/$STATICOS/$STATICARCH/`. ### Building from local source @@ -22,7 +21,7 @@ building packages * `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 +make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli STATICOS=linux STATICARCH=x86_64 static ``` ## Supported platforms @@ -30,13 +29,13 @@ make ENGINE_DIR=/path/to/engine CLI_DIR=/path/to/cli TARGETPLATFORM=linux/amd64 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 +make STATICOS=linux STATICARCH=x86_64 static +make STATICOS=linux STATICARCH=armel static +make STATICOS=linux STATICARCH=armhf static +make STATICOS=linux STATICARCH=aarch64 static +make STATICOS=darwin STATICARCH=x86_64 static +make STATICOS=darwin STATICARCH=aarch64 static +make STATICOS=windows STATICARCH=x86_64 static ``` > note: `darwin` only packages the docker cli and plugins. @@ -44,12 +43,6 @@ make TARGETPLATFORM=windows/amd64 static 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 +make STATICOS=linux STATICARCH=riscv64 static +make STATICOS=linux STATICARCH=s390x static ``` diff --git a/static/build-static b/static/build-static index 3810ab0dfd..4db67b233f 100755 --- a/static/build-static +++ b/static/build-static @@ -2,6 +2,8 @@ set -ex : "${CURDIR=}" +: "${STATICOS=}" +: "${STATICARCH=}" : "${TARGETPLATFORM=}" : "${TARGETOS=}" : "${TARGETARCH=}" @@ -12,38 +14,64 @@ if [ -z "$CURDIR" ]; then echo 'CURDIR is required. See README.md for usage.' exit 1 fi - -# break up 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 +if [[ -z "$STATICOS" ]] || [[ -z "$STATICARCH" ]]; then + # shellcheck disable=SC2016 + echo 'STATICOS and STATICARCH are required. See README.md for usage.' + exit 1 fi +# TODO: remove this once we support TARGETPLATFORM in download.docker.com folder structure +TARGETOS="$STATICOS" +# STATICARCH reverse lookup for compat with TARGETPLATFORM +case "$STATICARCH" in + "x86_64") + TARGETARCH="amd64" + ;; + "i386") + TARGETARCH="386" + ;; + "aarch64") + TARGETARCH="arm64" + ;; + "armhf") + TARGETARCH="arm" + TARGETVARIANT="v7" + ;; + "armel") + TARGETARCH="arm" + TARGETVARIANT="v6" + ;; +# "armel") +# TARGETARCH="arm" +# TARGETVARIANT="v5" +# ;; + "riscv64") + TARGETARCH="riscv64" + ;; + "ppc64le") + TARGETARCH="ppc64le" + ;; + "s390x") + TARGETARCH="s390x" + ;; + "mips") + TARGETARCH="mips" + ;; + "mipsle") + TARGETARCH="mipsle" + ;; + "mips64") + TARGETARCH="mips64" + ;; + "mips64le") + TARGETARCH="mips64le" + ;; + *) + TARGETARCH="$STATICARCH" + ;; +esac +TARGETPLATFORM="${TARGETOS}/${TARGETARCH}${TARGETVARIANT:+/${TARGETVARIANT}}" + build_cli() { ( cd "${CLI_DIR}" @@ -270,7 +298,7 @@ fi # create bundle ( # bundle is expected to have a tar.gz extension, unlike the other archives, which use .tgz - bundlesFilename="bundles-ce-static-${TARGETOS}-${TARGETARCH}${TARGETVARIANT}.tar.gz" + bundlesFilename="bundles-ce-static-${STATICOS}-${STATICARCH}.tar.gz" set -x cd "${buildDir}" rm -r */