--- /dev/null
+name: docker
+
+on:
+ push:
+ branches: master
+
+jobs:
+ docker:
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install packages
+ run: |
+ sudo apt-get update
+ sudo apt-get install -y autoconf automake build-essential cmake curl file libtool
+ - name: Cross build amd64/arm64 binary
+ run: |
+ for arch in amd64 arm64; do
+ env BUILD_TARGET=$arch ./scripts/cross-build.sh
+ cp build/ttyd ttyd.$arch
+ done
+ - uses: docker/setup-qemu-action@v1
+ - uses: docker/setup-buildx-action@v1
+ - uses: docker/login-action@v1
+ with:
+ username: ${{ secrets.DOCKER_HUB_USER }}
+ password: ${{ secrets.DOCKER_HUB_TOKEN }}
+ - name: build/push docker image
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: ./Dockerfile
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: |
+ tsl0922/ttyd:latest
+ - name: build/push docker image (alpine)
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: ./Dockerfile.alpine
+ platforms: linux/amd64,linux/arm64
+ push: true
+ tags: |
+ tsl0922/ttyd:alpine
\ No newline at end of file
-FROM ubuntu:18.04
-RUN apt-get update && apt-get install -y autoconf automake curl cmake git libtool make \
- && git clone --depth=1 https://github.com/tsl0922/ttyd.git /ttyd \
- && cd /ttyd && env BUILD_TARGET=x86_64 ./scripts/cross-build.sh
+FROM ubuntu:20.04
-FROM ubuntu:18.04
-COPY --from=0 /ttyd/build/ttyd /usr/bin/ttyd
-
-ADD https://github.com/krallin/tini/releases/download/v0.18.0/tini /sbin/tini
-RUN chmod +x /sbin/tini
+ARG TARGETARCH
+COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd
+RUN apt-get update && apt-get install -y --no-install-recommends tini && rm -rf /var/lib/apt/lists/*
EXPOSE 7681
WORKDIR /root
-ENTRYPOINT ["/sbin/tini", "--"]
+ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["ttyd", "bash"]
+++ /dev/null
-FROM ubuntu:18.04
-RUN apt-get update && apt-get install -y autoconf automake curl cmake git libtool make \
- && git clone --depth=1 https://github.com/tsl0922/ttyd.git /ttyd \
- && cd /ttyd && env BUILD_TARGET=x86_64 ./scripts/cross-build.sh
-
-FROM alpine
-COPY --from=0 /ttyd/build/ttyd /usr/bin/ttyd
-RUN apk add --no-cache bash tini
-
-EXPOSE 7681
-WORKDIR /root
-
-ENTRYPOINT ["/sbin/tini", "--"]
-CMD ["ttyd", "bash"]
--- /dev/null
+FROM alpine
+
+ARG TARGETARCH
+COPY ./ttyd.${TARGETARCH} /usr/bin/ttyd
+RUN apk add --no-cache bash tini
+
+EXPOSE 7681
+WORKDIR /root
+
+ENTRYPOINT ["/sbin/tini", "--"]
+CMD ["ttyd", "bash"]
build_ttyd
}
+[ "${BUILD_TARGET}" = "amd64" ] && BUILD_TARGET="x86_64"
+[ "${BUILD_TARGET}" = "arm64" ] && BUILD_TARGET="aarch64"
+
case ${BUILD_TARGET} in
i686|x86_64|aarch64|mips|mipsel|mips64|mips64el)
build "${BUILD_TARGET}-linux-musl" "${BUILD_TARGET}"