ci: support more platforms (#76)

This commit is contained in:
sigoden
2022-06-29 10:51:59 +08:00
committed by GitHub
parent fd02a53823
commit 5ee2c5504c
2 changed files with 74 additions and 26 deletions

View File

@@ -1,10 +1,18 @@
FROM rust:1.61 as builder
RUN rustup target add x86_64-unknown-linux-musl
RUN apt-get update && apt-get install --no-install-recommends -y musl-tools
WORKDIR /app
COPY . .
RUN cargo build --target x86_64-unknown-linux-musl --release
FROM alpine as builder
ARG REPO VER TARGETPLATFORM
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
TARGET="x86_64-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \
TARGET="aarch64-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/386" ]; then \
TARGET="i686-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \
TARGET="armv7-unknown-linux-musleabihf"; \
fi && \
wget https://github.com/${REPO}/releases/download/${VER}/dufs-${VER}-${TARGET}.tar.gz && \
tar -xf dufs-${VER}-${TARGET}.tar.gz && \
mv dufs /bin/
FROM scratch
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/dufs /bin/
ENTRYPOINT ["/bin/dufs"]
COPY --from=builder /bin/dufs /bin/dufs
ENTRYPOINT ["/bin/dufs"]