Skip to content

Commit 148d92f

Browse files
committed
workflow: build docker image for armv7 and s390x
1 parent e275bd6 commit 148d92f

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

.github/workflows/docker.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ jobs:
1414
run: |
1515
sudo apt-get update
1616
sudo apt-get install -y autoconf automake build-essential cmake curl file libtool
17-
- name: Cross build amd64/arm64 binary
17+
- name: Cross build multi-arch binary
1818
run: |
19-
for arch in amd64 arm64; do
19+
mkdir dist
20+
for arch in amd64 armv7 arm64 s390x; do
2021
env BUILD_TARGET=$arch ./scripts/cross-build.sh
21-
cp build/ttyd ttyd.$arch
22+
[ "$arch" = "armv7" ] && arch="arm"
23+
mkdir -p dist/$arch && cp build/ttyd dist/$arch/ttyd
2224
done
2325
- uses: docker/setup-qemu-action@v1
2426
- uses: docker/setup-buildx-action@v1
@@ -44,14 +46,14 @@ jobs:
4446
with:
4547
context: .
4648
file: ./Dockerfile
47-
platforms: linux/amd64,linux/arm64
49+
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x
4850
push: true
4951
tags: ${{ steps.docker_tag.outputs.DOCKER_TAG }}
5052
- name: build/push docker image (alpine)
5153
uses: docker/build-push-action@v2
5254
with:
5355
context: .
5456
file: ./Dockerfile.alpine
55-
platforms: linux/amd64,linux/arm64
57+
platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/s390x
5658
push: true
5759
tags: ${{ steps.docker_tag.outputs.ALPINE_TAG }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:20.04
22

33
ARG TARGETARCH
4-
COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd
4+
COPY ./dist/${TARGETARCH}/ttyd /usr/bin/ttyd
55
RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/*
66

77
EXPOSE 7681

Dockerfile.alpine

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM alpine
22

33
ARG TARGETARCH
4-
COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd
4+
COPY ./dist/${TARGETARCH}/ttyd /usr/bin/ttyd
55
RUN apk add --no-cache bash tini
66

77
EXPOSE 7681

scripts/cross-build.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,25 @@ build() {
153153
build_ttyd
154154
}
155155

156-
[ "${BUILD_TARGET}" = "amd64" ] && BUILD_TARGET="x86_64"
157-
[ "${BUILD_TARGET}" = "arm64" ] && BUILD_TARGET="aarch64"
156+
case ${BUILD_TARGET} in
157+
amd64) BUILD_TARGET="x86_64" ;;
158+
arm64) BUILD_TARGET="aarch64" ;;
159+
armv7) BUILD_TARGET="armv7l" ;;
160+
esac
158161

159162
case ${BUILD_TARGET} in
160-
i686|x86_64|aarch64|mips|mipsel|mips64|mips64el)
163+
i686|x86_64|aarch64|mips|mipsel|mips64|mips64el|s390x)
161164
build "${BUILD_TARGET}-linux-musl" "${BUILD_TARGET}"
162165
;;
163166
arm)
164-
build arm-linux-musleabi "${BUILD_TARGET}"
167+
build "${BUILD_TARGET}-linux-musleabi" "${BUILD_TARGET}"
165168
;;
166169
armhf)
167170
build arm-linux-musleabihf "${BUILD_TARGET}"
168171
;;
172+
armv7l)
173+
build armv7l-linux-musleabihf "${BUILD_TARGET}"
174+
;;
169175
*)
170176
echo "unknown cross target: ${BUILD_TARGET}" && exit 1
171177
esac

0 commit comments

Comments
 (0)