#!/bin/bash
# Download nym-node + build localhost/koopa-nym:latest
set -euo pipefail
ROOT=$(cd "$(dirname "$0")/../.." && pwd)
SRC="${NYM_SRC:-$ROOT/configs/nym}"
TAG="${NYM_IMAGE:-localhost/koopa-nym:latest}"
REL="${NYM_RELEASE_TAG:-nym-binaries-v2026.13-ziller}"
URL="${NYM_NODE_URL:-https://github.com/nymtech/nym/releases/download/${REL}/nym-node}"
cd "$SRC"
if [ ! -x nym-node ] || [ "${NYM_FORCE_DOWNLOAD:-0}" = "1" ]; then
  echo "download $URL"
  curl -fsSL -L -o nym-node.tmp "$URL"
  chmod +x nym-node.tmp
  mv nym-node.tmp nym-node
fi
./nym-node --version || true
podman build -t "$TAG" -f Containerfile .
echo "built $TAG"
