From a277698322acd479c910b7633877c6b1f0e06c52 Mon Sep 17 00:00:00 2001 From: sigoden Date: Sun, 7 Apr 2024 23:01:59 +0000 Subject: [PATCH] chore: update docker --- .github/workflows/release.yaml | 3 ++- Dockerfile | 23 +++++++++-------------- Dockerfile-release | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 15 deletions(-) create mode 100644 Dockerfile-release diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 788bfec..111998e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -177,11 +177,12 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v2 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: ${{ github.repository_owner }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push uses: docker/build-push-action@v4 with: + file: Dockerfile-release build-args: | REPO=${{ github.repository }} VER=${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile index 94219fb..d27bbb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,12 @@ -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 --platform=linux/amd64 messense/rust-musl-cross:x86_64-musl AS amd64 +COPY . . +RUN cargo install --path . --root / + +FROM --platform=linux/amd64 messense/rust-musl-cross:aarch64-musl AS arm64 +COPY . . +RUN cargo install --path . --root / + +FROM ${TARGETARCH} AS builder FROM scratch COPY --from=builder /bin/dufs /bin/dufs diff --git a/Dockerfile-release b/Dockerfile-release new file mode 100644 index 0000000..94219fb --- /dev/null +++ b/Dockerfile-release @@ -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"]