#!/usr/bin/env bash # Runs the mdlp-image to build the mod(s) defined under modding/mods/ (see # README.md) into modding/dist/mods/, entirely offline - every Go module # dependency mdlp needs was already fetched into the image by # ./mdlp-image.sh. # # Mounts the whole repository, not just modding/, because mdlp also needs the # game's own data directory (res/assets/ss_ee/data) as read-only reference # data (see the root README.md section 3 for how that gets populated). # # Usage: MODS="name1 name2" ./mdlp-run-image.sh [command...] # With no arguments, runs the image's baked-in process-mods.sh (its default # CMD), building every mod under mods/ (or only those named in MODS, if # set). 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]}")" MODDING_ROOT="$(pwd)" REPO_ROOT="$(cd .. && pwd)" fail() { echo "PREFLIGHT FAIL: $*" >&2; exit 1; } command -v docker >/dev/null 2>&1 \ || fail "docker not found in PATH" IMAGE="${MDLP_REGISTRY_IMAGE:-questshock/mdlp}" if [ -f "$MODDING_ROOT/../registry.env" ]; then # shellcheck disable=SC1091 source "$MODDING_ROOT/../registry.env" IMAGE="${MDLP_REGISTRY_IMAGE:-$IMAGE}" fi IMAGE_TAG="$(<"$MODDING_ROOT/mdlp-image/VERSION")" [ -n "$IMAGE_TAG" ] || fail "mdlp-image/VERSION is empty" IMAGE="$IMAGE:$IMAGE_TAG" docker image inspect "$IMAGE" >/dev/null 2>&1 \ || fail "$IMAGE not found locally - run ./mdlp-image.sh first" TTY_FLAGS="-i" [ -t 1 ] && TTY_FLAGS="-it" # shellcheck disable=SC2086 docker run --rm $TTY_FLAGS \ -v "$REPO_ROOT:/workspace" \ -e HOST_UID="$(id -u)" \ -e HOST_GID="$(id -g)" \ -e MODS="${MODS:-}" \ "$IMAGE" \ "$@"