Skip to content

Commit eafbb27

Browse files
Merge pull request #4 from NextronSystems/issue-license
feat: issue license server-side if required
2 parents 8f2fe7c + fcadb15 commit eafbb27

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ Thunderstorm is exposed on port **8080** by default.
2323

2424
## Contract-Token
2525

26-
Deploying Thunderstorm as a container requires a **non-host-based** Thunderstorm contract with at least one issued license.
26+
Deploying Thunderstorm as a container requires a **non-host-based** Thunderstorm contract.
2727

2828
On first start, the container uses your contract token to download the THOR binaries and persists them in a Docker volume so subsequent restarts are instant. You can omit the contract token afterwards as long as the volume exists.
2929

30+
During that first download the Nextron Portal issues a license server-side. Two optional environment variables tune this:
31+
32+
- `LICENSE_HOSTNAME` — host identity the portal binds the issued license to (default: `thunderstorm-container`). Keep it fixed so re-downloads reuse the same license slot instead of consuming new contract quota on every fresh volume.
33+
- `LICENSE_COMMENT` — comment shown for the issued license in the Nextron Portal.
34+
3035
A contract token can be retrieved from the [Nextron Portal](https://portal.nextron-systems.com/ui/contracts/contracts) under *Contracts & Licenses → Contracts → Actions → cloud icon → THOR Download Token*.
3136

3237
<img src="images/contract_token.png" alt="Contract Token location in Nextron Portal" width="500">

entrypoint.sh

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,33 @@ if [ ! -f "$TARGET_DIR/thor-util" ]; then
66
echo "CONTRACT_TOKEN is required to download THOR!" >&2
77
exit 0
88
fi
9-
echo "Downloading THOR..." && \
10-
wget -O "$TEMP_DIR/thor.zip" "https://portal.nextron-systems.com/api/voucher/download/$CONTRACT_TOKEN/thor/linux" && \
9+
echo "Downloading THOR and issue license (if required) ..."
10+
# The Nextron cloud issues a license server-side and binds it to the host
11+
# identity sent in the X-Hostname header. Two optional environment variables
12+
# tune this (see the Contract-Token section in the README):
13+
# LICENSE_HOSTNAME - host identity for the issued license. Defaults to the
14+
# fixed value "thunderstorm-container" so re-downloads
15+
# reuse the same license slot instead of consuming new
16+
# contract quota on every fresh volume.
17+
# LICENSE_COMMENT - optional comment shown for the license in the portal.
18+
#
19+
# ash has no arrays, so the optional X-Comment header is passed via a wrapper
20+
# function instead of "set --" (which would clobber the entrypoint's "$@").
21+
download_thor() {
22+
wget "$@" \
23+
--header="X-Token: $CONTRACT_TOKEN" \
24+
--header="X-OS: linux" \
25+
--header="X-Arch: amd64" \
26+
--header="X-Type: server" \
27+
--header="X-Hostname: ${LICENSE_HOSTNAME:-thunderstorm-container}" \
28+
-O "$TEMP_DIR/thor.zip" \
29+
"https://cloud.nextron-systems.com/api/public/thor10"
30+
}
31+
if [ -n "$LICENSE_COMMENT" ]; then
32+
download_thor --header="X-Comment: $LICENSE_COMMENT"
33+
else
34+
download_thor
35+
fi && \
1136
unzip -o -q "$TEMP_DIR/thor.zip" -d "$TARGET_DIR" && \
1237
rm "$TEMP_DIR/thor.zip"
1338
fi

0 commit comments

Comments
 (0)