2020-11-25 00:06:05 -05:00
|
|
|
#!/bin/sh
|
|
|
|
set -euxo pipefail
|
|
|
|
|
2020-11-26 15:05:21 -05:00
|
|
|
BUILD_SCRIPT="$1"
|
|
|
|
shift
|
|
|
|
[ "" == "$BUILD_SCRIPT" ] && [ -f '.ci/build.sh' ] && BUILD_SCRIPT='.ci/build.sh'
|
|
|
|
|
|
|
|
# this assists in cleanup, ie if a job was terminated, to be run in a jenkins finally {} or similar
|
|
|
|
if [ "$BUILD_SCRIPT" == "docker-chown" ]
|
|
|
|
then
|
|
|
|
# chown everything in this directory to this uid/gid
|
|
|
|
docker run --rm -v "$(pwd)":/tmp alpine chown -R "$UID:$(id -g)" /tmp
|
|
|
|
exit $?
|
|
|
|
fi
|
2020-11-25 00:06:05 -05:00
|
|
|
|
|
|
|
docker_build() {
|
|
|
|
export ARCH="$1"
|
|
|
|
shift
|
|
|
|
DOCKER_IMAGE="$1"
|
2020-11-26 15:05:21 -05:00
|
|
|
shift
|
2020-11-25 00:06:05 -05:00
|
|
|
|
|
|
|
# run it, but after, chown anything left in /tmp to *this* uid/gid, otherwise we can't delete them later...
|
2020-11-26 20:33:48 -05:00
|
|
|
docker run --rm -e ARCH -e BRANCH_NAME -e BUILD_UID="$UID" -e BUILD_GID="$(id -g)" -v "$(pwd)":/tmp -w /tmp "$DOCKER_IMAGE" sh -c "umask a=rwx; \"\$@\"; exit=\$?; chown -R '$UID:$(id -g)' /tmp; exit \$exit" -- "$@"
|
2020-11-25 00:06:05 -05:00
|
|
|
}
|
|
|
|
|
2020-11-26 15:05:21 -05:00
|
|
|
docker_build 'amd64' 'alpine' "$BUILD_SCRIPT" "$@"
|
2020-11-25 00:06:05 -05:00
|
|
|
|
|
|
|
# before first multiarch image, must register binfmt handlers
|
|
|
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
|
|
|
2020-11-26 15:05:21 -05:00
|
|
|
docker_build 'i386' 'multiarch/alpine:i386-latest-stable' "$BUILD_SCRIPT" "$@"
|
|
|
|
docker_build 'aarch64' 'multiarch/alpine:aarch64-latest-stable' "$BUILD_SCRIPT" "$@"
|
|
|
|
docker_build 'armv7' 'multiarch/alpine:armv7-latest-stable' "$BUILD_SCRIPT" "$@"
|
2022-02-23 01:10:23 -05:00
|
|
|
docker_build 'armhf' 'multiarch/alpine:armhf-latest-stable' "$BUILD_SCRIPT" "$@"
|
2020-11-26 15:05:21 -05:00
|
|
|
docker_build 'ppc64le' 'multiarch/alpine:ppc64le-latest-stable' "$BUILD_SCRIPT" "$@"
|