Skip to content

Commit cd93fe7

Browse files
committed
chore: portal dist scaffolding for image builds
1 parent 9f344c3 commit cd93fe7

5 files changed

Lines changed: 59 additions & 0 deletions

File tree

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ CORS_ALLOWED_ORIGINS=
2525
# are rejected with 413.
2626
MAX_HTTP_BODY_SIZE=
2727

28+
# Directory holding the built portal dist; the node serves it on the REST
29+
# port with an SPA fallback. Empty/missing = portal serving disabled
30+
# (the REST API is unaffected).
31+
PORTAL_DIST_PATH=
32+
2833
RUST_LOG=
2934
OTEL_EXPORTER_OTLP_ENDPOINT=

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@ COPY --from=builder /build/target/release/aruna .
2020
COPY --from=builder /build/target/release/aruna-doctor .
2121
COPY --from=builder /build/target/bin/iroh-doctor .
2222

23+
# Portal dist baked into the image (stage 1 delivery). Populate portal-dist/
24+
# via scripts/fetch-portal.sh before building; an empty directory just
25+
# disables portal serving at runtime.
26+
ENV PORTAL_DIST_PATH=/var/lib/aruna/portal
27+
COPY portal-dist/ /var/lib/aruna/portal/
28+
2329
CMD [ "/run/aruna" ]

portal-dist/.gitkeep

Whitespace-only changes.

portal.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": "",
3+
"sha256": "",
4+
"url": ""
5+
}

scripts/fetch-portal.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# Resolves portal.lock and installs the pinned portal dist into portal-dist/
3+
# for image builds and local development. Refuses to install a dist whose
4+
# sha256 does not match the pin; there is no unverified mode.
5+
set -euo pipefail
6+
7+
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
8+
LOCK="$ROOT/portal.lock"
9+
DEST="${1:-$ROOT/portal-dist}"
10+
11+
field() { sed -n "s/.*\"$1\": *\"\([^\"]*\)\".*/\1/p" "$LOCK" | head -n1; }
12+
VERSION="$(field version)"
13+
SHA256="$(field sha256)"
14+
URL="$(field url)"
15+
16+
if [ -z "$URL" ] || [ -z "$SHA256" ]; then
17+
echo "portal.lock carries no pinned url/sha256 yet." >&2
18+
echo "Either pin a portal release in portal.lock or place a built dist into $DEST manually." >&2
19+
exit 1
20+
fi
21+
22+
TMP="$(mktemp -d)"
23+
trap 'rm -rf "$TMP"' EXIT
24+
25+
echo "Fetching aruna portal dist ${VERSION} from ${URL}"
26+
curl -fsSL "$URL" -o "$TMP/dist.tar.gz"
27+
echo "$SHA256 $TMP/dist.tar.gz" | sha256sum -c - >/dev/null
28+
29+
mkdir -p "$TMP/unpack"
30+
tar -xzf "$TMP/dist.tar.gz" -C "$TMP/unpack"
31+
SRC="$TMP/unpack"
32+
if [ -d "$TMP/unpack/dist" ]; then
33+
SRC="$TMP/unpack/dist"
34+
fi
35+
if [ ! -f "$SRC/index.html" ]; then
36+
echo "Portal tarball holds no index.html; refusing to install." >&2
37+
exit 1
38+
fi
39+
40+
rm -rf "$DEST"
41+
mkdir -p "$(dirname "$DEST")"
42+
mv "$SRC" "$DEST"
43+
echo "Portal dist ${VERSION} installed at $DEST"

0 commit comments

Comments
 (0)