Verified Commit 81aa1690 authored by noplanman's avatar noplanman

Initial commit.

FROM resin/${BORG_ARCH}-python:3.6-slim
# install dev requirements
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
build-essential git \
fuse libfuse-dev pkg-config \
libssl-dev libacl1-dev \
zlib1g-dev liblz4-dev; \
rm -rf /var/lib/apt/lists/*;
# install borg + dependencies
RUN set -ex; \
git clone .; \
git checkout ${BORG_VERSION}; \
pip install --upgrade pip;
RUN set -ex; pip install -r requirements.d/development.txt;
RUN set -ex; pip install -r requirements.d/fuse.txt;
RUN set -ex; pip install -e .;
# create standalone binary
RUN set -ex; \
pip install pyinstaller; \
pyinstaller --log-level DEBUG -F -n borg-${BORG_ARCH} src/borg/;
RUN ln -s "${BORG_BUILD_DIR}/borg-${BORG_ARCH}" /usr/bin/borg
# Borg Binary Builder
Build [BorgBackup] binaries on any platform, for any architecture, using docker.
## Usage
### Build image
`./ <arch> [<version>]`
See the [list of available architectures] ([on GitHub][available-architectures-github])
- Build version `1.1.7` for `aarch64`
`./ aarch64 1.1.7`
- Build version `1.1.5` for Raspberry Pi 3
`./ raspberrypi3 1.1.5`
### Extract borg binary
`./ <arch> [<binary_save_location>]`
**Note:** This will overwrite the file at `binary_save_location` if it already exists!
- Extract borg binary for `aarch64` to `borg-aarch64` in current folder
`./ aarch64 borg-aarch64`
- Extract borg binary for Raspberry Pi 3 to `/homes/lemoi/borg`
`./ raspberrypi3 /homes/lemoi/borg`
## How this works
### Build
The `` script downloads the appropriate starter docker image that contains the necessary QEMU binary for building and registers it in the build agent.
For more details, check the [Hypriot blog post] that explains it in more depth.
Then, the docker image is built for the requested architecture.
This is basically done by following the flow of setting up a [BorgBackup development environment] and [creating the standalone binary]. (For more info on this, just have a look at the `Dockerfile`)
### Extract
The `` script extracts the built binary from the image created using ``.
This basically starts a container from the built image for your selected architecture and writes the binary out to the file path you passed as a parameter.
[BorgBackup]: "BorgBackup on GitHub"
[BorgBackup development environment]: "BorgBackup development environment"
[creating the standalone binary]: "Create standalone binary"
[list of available architectures]: "List of available Architectures"
[available-architectures-github]: "List of available Architectures on GitHub"
[Hypriot blog post]: "Setup a simple CI pipeline to build Docker images for ARM"
#!/usr/bin/env bash
# Usage: ./ <arch> [<version>]
# For available architectures see:
if [ -z "${BORG_ARCH}" ]; then
echo "Usage: ./ <arch> [<version>]";
echo "- No arch provided -";
exit 1;
echo "Building BorgBackup ${BORG_VERSION} for ${BORG_ARCH}"
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build \
--build-arg "BORG_ARCH=${BORG_ARCH}" \
--build-arg "BORG_VERSION=${BORG_VERSION}" \
-t "borg:${BORG_ARCH}" .
#!/usr/bin/env bash
# Usage: ./ <arch> [<binary_save_location>]
#if [[ "$(docker images -q "borg:${BORG_ARCH}" 2> /dev/null)" == "" ]]; then
if ! docker inspect "borg:${BORG_ARCH}" >/dev/null 2>&1; then
echo "Couldn't find the 'borg:${BORG_ARCH}' image!"
echo "Create the image first, using './ ${BORG_ARCH}'"
exit 1
#docker run -v "${PWD}":"/opt/mount" --rm --entrypoint \
# cp "borg:${BORG_ARCH}" "/usr/bin/borg" "/opt/mount/${BORG_BINARY}"
docker run --rm --entrypoint cat "borg:${BORG_ARCH}" /usr/bin/borg > "${BORG_BINARY}"
chmod +x "${BORG_BINARY}"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment