47 lines
1.5 KiB
Bash
Executable File
47 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs the hacked build-image against this folder to compile hacked/ (the
|
|
# vendored InkyBlackness HackEd snapshot, see README.md) for Linux and
|
|
# Windows, entirely offline - every Go module dependency it needs was already
|
|
# fetched into the image by ./hacked-build-image.sh.
|
|
#
|
|
# Output lands in dist/ (both platforms, packaged as .tgz/.zip).
|
|
#
|
|
# Usage: ./hacked-build-run-image.sh [command...]
|
|
# With no arguments, runs the image's baked-in build-hacked.sh (its default
|
|
# CMD). Pass a command (e.g. `bash`) to get a shell in the build environment
|
|
# instead, useful for debugging a failed build.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "${BASH_SOURCE[0]}")"
|
|
ROOT="$(pwd)"
|
|
|
|
fail() { echo "PREFLIGHT FAIL: $*" >&2; exit 1; }
|
|
|
|
command -v docker >/dev/null 2>&1 \
|
|
|| fail "docker not found in PATH"
|
|
|
|
IMAGE="${HACKED_REGISTRY_IMAGE:-questshock/hacked-builder}"
|
|
if [ -f "$ROOT/../registry.env" ]; then
|
|
# shellcheck disable=SC1091
|
|
source "$ROOT/../registry.env"
|
|
IMAGE="${HACKED_REGISTRY_IMAGE:-$IMAGE}"
|
|
fi
|
|
|
|
IMAGE_TAG="$(<"$ROOT/hacked-build-image/VERSION")"
|
|
[ -n "$IMAGE_TAG" ] || fail "hacked-build-image/VERSION is empty"
|
|
IMAGE="$IMAGE:$IMAGE_TAG"
|
|
|
|
docker image inspect "$IMAGE" >/dev/null 2>&1 \
|
|
|| fail "$IMAGE not found locally - run ./hacked-build-image.sh first"
|
|
|
|
TTY_FLAGS="-i"
|
|
[ -t 1 ] && TTY_FLAGS="-it"
|
|
|
|
# shellcheck disable=SC2086
|
|
docker run --rm $TTY_FLAGS \
|
|
-v "$ROOT:/workspace" \
|
|
-e HOST_UID="$(id -u)" \
|
|
-e HOST_GID="$(id -g)" \
|
|
"$IMAGE" \
|
|
"$@"
|