chore: update docker

This commit is contained in:
sigoden 2024-04-07 23:01:59 +00:00
parent 0ff2b15c9a
commit a277698322
3 changed files with 30 additions and 15 deletions

View file

@ -177,11 +177,12 @@ jobs:
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v4 uses: docker/build-push-action@v4
with: with:
file: Dockerfile-release
build-args: | build-args: |
REPO=${{ github.repository }} REPO=${{ github.repository }}
VER=${{ github.ref_name }} VER=${{ github.ref_name }}

View file

@ -1,17 +1,12 @@
FROM alpine as builder FROM --platform=linux/amd64 messense/rust-musl-cross:x86_64-musl AS amd64
ARG REPO VER TARGETPLATFORM COPY . .
RUN if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ RUN cargo install --path . --root /
TARGET="x86_64-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm64" ]; then \ FROM --platform=linux/amd64 messense/rust-musl-cross:aarch64-musl AS arm64
TARGET="aarch64-unknown-linux-musl"; \ COPY . .
elif [ "$TARGETPLATFORM" = "linux/386" ]; then \ RUN cargo install --path . --root /
TARGET="i686-unknown-linux-musl"; \
elif [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ FROM ${TARGETARCH} AS builder
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 FROM scratch
COPY --from=builder /bin/dufs /bin/dufs COPY --from=builder /bin/dufs /bin/dufs

19
Dockerfile-release Normal file
View file

@ -0,0 +1,19 @@
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 /bin/dufs /bin/dufs
STOPSIGNAL SIGINT
ENTRYPOINT ["/bin/dufs"]