build-base.sh 1 KB
Newer Older
1 2 3 4 5 6 7 8
#!/usr/bin/env sh

# Usage: ./build-base.sh <arch>

# This script is used to build a base image for the given architecture, to make future building much faster.
# User needs to be logged in via "docker login" for the push to work.

# For available architectures see:
9
# https://www.balena.io/docs/reference/base-images/base-images/#balena-base-images
10

11 12
set -ex

13 14 15 16 17 18 19 20
BORG_ARCH=${1}

if [ -z "${BORG_ARCH}" ]; then
    echo "Usage: ./build-base.sh <arch>";
    echo "No arch provided";
    exit 1;
fi

21
DOCKER_IMAGE=noplanman/borg-binary-builder:base-1.1.14-${BORG_ARCH}
22 23 24 25 26 27 28 29 30 31
echo "Building ${DOCKER_IMAGE}"

# https://blog.hypriot.com/post/setup-simple-ci-pipeline-for-arm-images/
docker run --rm --privileged multiarch/qemu-user-static:register --reset

docker build \
    --build-arg "BORG_ARCH=${BORG_ARCH}" \
    -t "${DOCKER_IMAGE}" \
    -f Dockerfile.base .

32
# Output built borg binary version to ensure the binary works.
33 34
docker run --rm "${DOCKER_IMAGE}" borg --version

35 36
echo "Pushing to docker hub"
docker push "${DOCKER_IMAGE}"