From 1fb320e2bd0c66f6d80031aabbdcd89f475539c4 Mon Sep 17 00:00:00 2001 From: Sertac TULLUK Date: Sat, 17 Jan 2026 16:09:49 +0300 Subject: [PATCH] Add Docker scripts for ARM static builds --- Dockerfile | 7 +++++++ README.md | 13 +++++++++++++ dockerbuild.sh | 25 +++++++++++++++++++++++++ indockerbuild.sh | 15 +++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 Dockerfile create mode 100755 dockerbuild.sh create mode 100755 indockerbuild.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2876894 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +ARG BASE_IMAGE +FROM ${BASE_IMAGE} + +ARG TARGET +ENV TARGET=${TARGET} + +WORKDIR /work diff --git a/README.md b/README.md index cf45180..606307b 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,19 @@ you will help support: - Unpack and put the binary somewhere in your PATH (i.e. `/usr/local/bin` on linux and macos) - Note that the binary is not code signed and will cause a warning on windows and macos when running. This will be fixed later, but for now you can find a workaround via your favorite search engine. +### Build static ARM binaries (Docker) + +This repository includes Docker scripts for building static ARM binaries with musl. + +- ARM64 (aarch64): + - `./dockerbuild.sh aarch64-unknown-linux-musl` + - `./indockerbuild.sh aarch64-unknown-linux-musl` + - Output: `dist/aarch64-unknown-linux-musl/gdrive` +- ARM32 (armv7): + - `./dockerbuild.sh armv7-unknown-linux-musleabihf` + - `./indockerbuild.sh armv7-unknown-linux-musleabihf` + - Output: `dist/armv7-unknown-linux-musleabihf/gdrive` + ### Add google account to gdrive - Run `gdrive account add` diff --git a/dockerbuild.sh b/dockerbuild.sh new file mode 100755 index 0000000..4a55e39 --- /dev/null +++ b/dockerbuild.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +TARGET="${1:-aarch64-unknown-linux-musl}" +case "${TARGET}" in + aarch64-unknown-linux-musl) + BASE_IMAGE="messense/rust-musl-cross:aarch64-musl" + ;; + armv7-unknown-linux-musleabihf) + BASE_IMAGE="messense/rust-musl-cross:armv7-musleabihf" + ;; + *) + echo "Unsupported target: ${TARGET}" + exit 1 + ;; +esac + +IMAGE="gdrive-build:${TARGET}" + +docker build \ + --build-arg TARGET="${TARGET}" \ + --build-arg BASE_IMAGE="${BASE_IMAGE}" \ + -t "${IMAGE}" \ + -f Dockerfile \ + . diff --git a/indockerbuild.sh b/indockerbuild.sh new file mode 100755 index 0000000..ca10198 --- /dev/null +++ b/indockerbuild.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail + +TARGET="${1:-aarch64-unknown-linux-musl}" +OUT_DIR="${2:-$(pwd)/dist/${TARGET}}" +IMAGE="gdrive-build:${TARGET}" + +mkdir -p "${OUT_DIR}" + +docker run --rm \ + -v "$(pwd)":/work \ + -v "${OUT_DIR}":/out \ + -w /work \ + "${IMAGE}" \ + /bin/sh -c "cargo build --release --target ${TARGET} && cp target/${TARGET}/release/gdrive /out/gdrive"