2020-03-22 01:29:59 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
BUILD_DATE=$(date)
|
|
|
|
VERSION=$1
|
2020-03-22 21:32:42 +00:00
|
|
|
MIGRATIONS=$2
|
2020-03-22 01:29:59 +00:00
|
|
|
|
|
|
|
function require() {
|
|
|
|
if [ "$1" = "" ]; then
|
|
|
|
echo "input '$2' required"
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function print_help() {
|
|
|
|
echo "build.sh"
|
|
|
|
echo ""
|
|
|
|
echo "Usage:"
|
2020-03-22 21:32:42 +00:00
|
|
|
echo " build.sh [version] [migrations]"
|
2020-03-22 01:29:59 +00:00
|
|
|
echo ""
|
|
|
|
echo "Args:"
|
|
|
|
echo " version: The version of the current container"
|
2020-03-22 21:32:42 +00:00
|
|
|
echo " migrations: (optional) Whether to build the migrations container as well"
|
2020-03-22 01:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
require "$VERSION" "version"
|
|
|
|
|
|
|
|
set -xe
|
|
|
|
|
|
|
|
# from `cargo install cross`
|
|
|
|
cross build \
|
|
|
|
--target aarch64-unknown-linux-musl \
|
|
|
|
--release
|
|
|
|
|
|
|
|
mkdir -p artifacts
|
2020-03-22 23:06:49 +00:00
|
|
|
rm -rf artifacts/relay
|
2020-03-22 01:29:59 +00:00
|
|
|
cp ./target/aarch64-unknown-linux-musl/release/relay artifacts/relay
|
|
|
|
|
|
|
|
# from `sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes`
|
|
|
|
docker build \
|
|
|
|
--pull \
|
|
|
|
--no-cache \
|
|
|
|
--build-arg BUILD_DATE="${BUILD_DATE}" \
|
|
|
|
--build-arg TAG="${TAG}" \
|
2020-03-22 21:18:36 +00:00
|
|
|
-f Dockerfile.arm64v8 \
|
2020-03-22 01:29:59 +00:00
|
|
|
-t "asonix/relay:${VERSION}-arm64v8" \
|
|
|
|
-t "asonix/relay:latest-arm64v8" \
|
|
|
|
-t "asonix/relay:latest" \
|
|
|
|
./artifacts
|
|
|
|
|
|
|
|
docker push "asonix/relay:${VERSION}-arm64v8"
|
|
|
|
docker push "asonix/relay:latest-arm64v8"
|
|
|
|
docker push "asonix/relay:latest"
|
2020-03-22 21:32:42 +00:00
|
|
|
|
2020-03-22 23:06:49 +00:00
|
|
|
if [ "${MIGRATIONS}" = "migrations" ]; then
|
|
|
|
rm -rf artifacts/migrations
|
|
|
|
cp -r ./migrations artifacts/migrations
|
|
|
|
|
2020-03-22 21:32:42 +00:00
|
|
|
docker build \
|
|
|
|
--pull \
|
|
|
|
--no-cache \
|
|
|
|
--build-arg BUILD_DATE="${BUILD_DATE}" \
|
|
|
|
--build-arg TAG="${TAG}" \
|
|
|
|
-f Dockerfile.migrations.arm64v8 \
|
|
|
|
-t "asonix/relay-migrations:${VERSION}-arm64v8" \
|
|
|
|
-t "asonix/relay-migrations:latest-arm64v8" \
|
|
|
|
-t "asonix/relay-migrations:latest" \
|
|
|
|
./artifacts
|
|
|
|
|
|
|
|
docker push "asonix/relay-migrations:${VERSION}-arm64v8"
|
|
|
|
docker push "asonix/relay-migrations:latest-arm64v8"
|
|
|
|
docker push "asonix/relay-migrations:latest"
|
|
|
|
fi
|