55 lines
2.0 KiB
Bash
Executable File
55 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Runs INSIDE the builder container (see compose.yml / Dockerfile):
|
|
#
|
|
# docker compose run --rm release-httptoolkit
|
|
#
|
|
# Clones upstream, applies our patches + overlay, builds the UI, embeds it into
|
|
# the server and compiles a single self-contained binary -> builds/httptoolkit.
|
|
#
|
|
set -euo pipefail
|
|
cd /source
|
|
|
|
# The repo is bind-mounted from the host (owned by a different uid), so git
|
|
# refuses to operate on it until we mark it safe:
|
|
git config --global --add safe.directory '*'
|
|
|
|
OUT_DIR="/source/builds"
|
|
mkdir -p "$OUT_DIR"
|
|
|
|
# Clone upstream -> scripts/patch.sh -> build UI -> embed -> bun compile.
|
|
# Produces dist/httptoolkit:
|
|
bash scripts/build.sh
|
|
|
|
# Smoke-test the binary before we consider it releasable: it must serve the UI
|
|
# and bring up the management API, i.e. all native modules actually load.
|
|
#
|
|
# Critically, we hide the build tree first. Paths like
|
|
# /source/httptoolkit-server/node_modules/... are baked into the bundle, so any
|
|
# native module that bun failed to embed still *works* here while those files sit
|
|
# on disk - and then dies on a user's machine with "Cannot find module". Moving
|
|
# the tree aside forces the binary to prove it is genuinely self-contained.
|
|
HIDDEN=/source/.htk-server-hidden
|
|
rm -rf "$HIDDEN"
|
|
mv httptoolkit-server "$HIDDEN"
|
|
trap 'mv "$HIDDEN" /source/httptoolkit-server 2>/dev/null || true' EXIT
|
|
|
|
echo
|
|
echo "### Smoke 1/2: self-containment (build tree hidden)"
|
|
bash scripts/smoke.sh dist/httptoolkit
|
|
|
|
mv "$HIDDEN" /source/httptoolkit-server
|
|
trap - EXIT
|
|
|
|
# Second pass with the tree back, because the WebSocket check needs node and the
|
|
# server's node_modules to run a real mockttp admin client against the binary.
|
|
# That path (admin session + subscription stream) is invisible to HTTP probing and
|
|
# is exactly where bun's built-in `ws` shim used to crash the server.
|
|
echo
|
|
echo "### Smoke 2/2: admin WebSocket + subscription stream"
|
|
WS_CHECK=1 bash scripts/smoke.sh dist/httptoolkit
|
|
|
|
cp -v dist/httptoolkit "$OUT_DIR/httptoolkit"
|
|
echo "==> Artifacts:"
|
|
ls -lh "$OUT_DIR"
|