From: Shuanglei Tao Date: Thu, 28 Jan 2021 13:06:24 +0000 (+0800) Subject: workflow: build docker image for armv7 and s390x X-Git-Url: http://git.prime8.dev/?a=commitdiff_plain;h=148d92f7592da39f381068c0b22db6a95186cf1a;p=ttyd.git workflow: build docker image for armv7 and s390x --- diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 312d7ed..4ff2624 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,11 +14,13 @@ jobs: run: | sudo apt-get update sudo apt-get install -y autoconf automake build-essential cmake curl file libtool - - name: Cross build amd64/arm64 binary + - name: Cross build multi-arch binary run: | - for arch in amd64 arm64; do + mkdir dist + for arch in amd64 armv7 arm64 s390x; do env BUILD_TARGET=$arch ./scripts/cross-build.sh - cp build/ttyd ttyd.$arch + [ "$arch" = "armv7" ] && arch="arm" + mkdir -p dist/$arch && cp build/ttyd dist/$arch/ttyd done - uses: docker/setup-qemu-action@v1 - uses: docker/setup-buildx-action@v1 @@ -44,7 +46,7 @@ jobs: with: context: . file: ./Dockerfile - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x push: true tags: ${{ steps.docker_tag.outputs.DOCKER_TAG }} - name: build/push docker image (alpine) @@ -52,6 +54,6 @@ jobs: with: context: . file: ./Dockerfile.alpine - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x push: true tags: ${{ steps.docker_tag.outputs.ALPINE_TAG }} diff --git a/Dockerfile b/Dockerfile index 9f90cc7..03603f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:20.04 ARG TARGETARCH -COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd +COPY ./dist/${TARGETARCH}/ttyd /usr/bin/ttyd RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/* EXPOSE 7681 diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 9347dfe..844b53c 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,7 +1,7 @@ FROM alpine ARG TARGETARCH -COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd +COPY ./dist/${TARGETARCH}/ttyd /usr/bin/ttyd RUN apk add --no-cache bash tini EXPOSE 7681 diff --git a/scripts/cross-build.sh b/scripts/cross-build.sh index 185d838..81efadf 100755 --- a/scripts/cross-build.sh +++ b/scripts/cross-build.sh @@ -153,19 +153,25 @@ build() { build_ttyd } -[ "${BUILD_TARGET}" = "amd64" ] && BUILD_TARGET="x86_64" -[ "${BUILD_TARGET}" = "arm64" ] && BUILD_TARGET="aarch64" +case ${BUILD_TARGET} in + amd64) BUILD_TARGET="x86_64" ;; + arm64) BUILD_TARGET="aarch64" ;; + armv7) BUILD_TARGET="armv7l" ;; +esac case ${BUILD_TARGET} in - i686|x86_64|aarch64|mips|mipsel|mips64|mips64el) + i686|x86_64|aarch64|mips|mipsel|mips64|mips64el|s390x) build "${BUILD_TARGET}-linux-musl" "${BUILD_TARGET}" ;; arm) - build arm-linux-musleabi "${BUILD_TARGET}" + build "${BUILD_TARGET}-linux-musleabi" "${BUILD_TARGET}" ;; armhf) build arm-linux-musleabihf "${BUILD_TARGET}" ;; + armv7l) + build armv7l-linux-musleabihf "${BUILD_TARGET}" + ;; *) echo "unknown cross target: ${BUILD_TARGET}" && exit 1 esac