Skip to content

Commit

Permalink
static: keep old arches to match folder structure
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jan 25, 2023
1 parent f4326c0 commit e88c968
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 79 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
20 changes: 10 additions & 10 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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') {
Expand All @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion static/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 15 additions & 22 deletions static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -22,34 +21,28 @@ 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

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.
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
```
90 changes: 59 additions & 31 deletions static/build-static
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
set -e

: "${CURDIR=}"
: "${STATICOS=}"
: "${STATICARCH=}"
: "${TARGETPLATFORM=}"
: "${TARGETOS=}"
: "${TARGETARCH=}"
Expand All @@ -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}"
Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit e88c968

Please sign in to comment.