62 lines
3.3 KiB
Bash
Executable File
62 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# build-image.sh — build the StakeSquid dshackle fork image with a WIRE-CORRECT version.
|
|
#
|
|
# dRPC edges record each provider's dshackle version (Global.version, sent in every
|
|
# Describe response and SubscribeChainStatus BuildInfo) and deprioritize providers
|
|
# whose string doesn't match the expected release. gradle's getVersion() only yields
|
|
# the clean release string on an EXACT tag match; one patch commit past the tag would
|
|
# report "<next>-SNAPSHOT" to every edge. So: force-move the base release tag onto the
|
|
# patch HEAD locally before building (never push that tag), which makes our build
|
|
# report exactly what stock drpcorg/dshackle:<version> reports (verified against a
|
|
# live gateway: version.app=0.79.10).
|
|
#
|
|
# Usage: ./build-image.sh [base-tag] [suffix]
|
|
# base-tag: upstream release our branch is based on (default v0.79.10)
|
|
# suffix: local image tag suffix (default ss1) -> stakesquid/dshackle:<ver>-<suffix>
|
|
#
|
|
# Per upstream release: rebase reload-removal onto the new tag, bump the default here,
|
|
# rerun. Distribute with: docker save stakesquid/dshackle:<ver>-<suffix> | ssh <gw> docker load
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
BASE_TAG=${1:-v0.79.10}
|
|
SUFFIX=${2:-ss1}
|
|
VER=${BASE_TAG#v}
|
|
|
|
git tag -f "$BASE_TAG" HEAD >/dev/null # local only - makes getVersion() exact-match
|
|
|
|
# Submodules are REQUIRED at build time (SSH urls -> rewrite to https; controller
|
|
# has no github key). The `public` submodule feeds foundation's resources
|
|
# (compatible-clients.yaml etc.) - foundation is consumed as a mavenLocal
|
|
# artifact, so it must be REPUBLISHED whenever the submodule moves, and the
|
|
# main build cleaned so jib can't reuse stale layers. Skipping any of this
|
|
# shipped a boot-crashing image on 2026-07-30 (ss1: Spring died on missing
|
|
# compatible-clients.yaml) - hence the hard gate below.
|
|
git config url."https://github.com/".insteadOf "git@github.com:" 2>/dev/null || true
|
|
git submodule sync -q && git submodule update --init --recursive
|
|
test -f foundation/src/main/resources/public/compatible-clients.yaml \
|
|
|| { echo "FATAL: public submodule missing compatible-clients.yaml"; exit 1; }
|
|
|
|
export JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-21-openjdk-amd64}
|
|
./gradlew -p foundation publishToMavenLocal -q
|
|
./gradlew clean -q
|
|
docker build -q -t drpc-dshackle . >/dev/null
|
|
./gradlew jibDockerBuild -Djib.to.image="stakesquid/dshackle:${VER}-${SUFFIX}" -x test
|
|
|
|
echo "--- resource gate (foundation jar inside the image):"
|
|
docker run --rm --entrypoint sh "stakesquid/dshackle:${VER}-${SUFFIX}" -c \
|
|
'ls /app/libs/foundation-*.jar >/dev/null' || { echo FATAL: no foundation jar; exit 1; }
|
|
python3 - "$VER" "$SUFFIX" <<'PY'
|
|
import subprocess, sys, zipfile, io
|
|
ver, suf = sys.argv[1], sys.argv[2]
|
|
jar = subprocess.run(["docker", "run", "--rm", "--entrypoint", "sh",
|
|
f"stakesquid/dshackle:{ver}-{suf}", "-c",
|
|
"cat /app/libs/foundation-*.jar"], capture_output=True).stdout
|
|
names = zipfile.ZipFile(io.BytesIO(jar)).namelist()
|
|
assert "public/compatible-clients.yaml" in names, "FATAL: compatible-clients.yaml not packaged"
|
|
print("resource gate OK: public/compatible-clients.yaml present in foundation jar")
|
|
PY
|
|
|
|
echo "--- wire version check (must equal stock ${VER}):"
|
|
docker run --rm --entrypoint cat "stakesquid/dshackle:${VER}-${SUFFIX}" \
|
|
/app/resources/version.properties
|