]> prime8.dev >> repos - ttyd.git/commitdiff
workflow: build docker image for armv7 and s390x
authorShuanglei Tao <tsl0922@gmail.com>
Thu, 28 Jan 2021 13:06:24 +0000 (21:06 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Thu, 28 Jan 2021 14:48:08 +0000 (22:48 +0800)
.github/workflows/docker.yml
Dockerfile
Dockerfile.alpine
scripts/cross-build.sh

index 312d7eddea52a29d187695a9c2a6cbf2b5a6bbf7..4ff26248002c83c6a5ada52585bf2b218765cdb3 100644 (file)
@@ -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 }}
index 9f90cc794f48caf257804236bd0bf6039613495e..03603f479d21b15cdb765105f673c23a6d8e4378 100644 (file)
@@ -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
index 9347dfeaa2e47f0dbbf085e1505613ceca114a00..844b53c4a2f4569f18a2dc5430efeb59f3c28f83 100644 (file)
@@ -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
index 185d838052ad75c5723efda722ddbf96906c779a..81efadf0dbc83199427df3375b00310b3f9d84fe 100755 (executable)
@@ -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