transfer.sh/hooks/build
Andrea Spacca 3bad0912c4 ISSUE-313
2020-06-14 19:48:51 +02:00

57 lines
No EOL
2.2 KiB
Bash

#!/usr/bin/env bash
set -eu
echo "build"
source hooks/.config
echo "Will build the following architectures: $verified_build_architectures"
echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
for arch in ${verified_build_architectures[@]}; do
echo "building $arch"
echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
BASE_IMAGE_PREFIX="${base_image_prefix_map[${arch}]}"
docker build \
--build-arg GOOS=linux \
--build-arg GOARCH=${arch} \
--file $DOCKERFILE_PATH \
--tag "${IMAGE_NAME}-${arch}" \
.
done
echo "images built:"
echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
docker image ls
# https://github.com/moby/moby/issues/36552
#
tempdir=$(mktemp -d -t yolo.XXXXXXXX)
cd $tempdir
for arch in ${verified_build_architectures[@]}; do
echo "yolo fixing platform $arch"
echo "⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
manifest_arch=${docker_to_manifest_map[${arch}]}
docker save "${IMAGE_NAME}-${arch}"| tar xv
for filename in */json; do
[ -e "$filename" ] || continue
jq --compact-output 'del(.architecture)' < "$filename" | sponge "$filename"
done
for filename in *.json; do
[ -e "$filename" ] || continue
! [ $filename = "manifest.json" ] || continue
jq --arg architecture "$manifest_arch" \
--compact-output '.architecture=$architecture' < "$filename" | sponge "$filename"
done
tar cv . | docker load
rm -rf $tempdir/*
done
trap "exit 1" HUP INT PIPE QUIT TERM
trap "rm -rf $tempdir" EXIT