mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-31 03:56:15 +00:00
Config system overhaul: - Add mesh-public topology (5 Docker nodes + external pub node at 217.77.8.91) - Refactor generate-configs.sh to read topology YAML files directly, replacing hardcoded lookup functions, with multi-char node ID support - Generate npubs.env with all node npubs; sourced by test scripts and injected into containers via docker-compose env_file directive - Add .env with COMPOSE_PROFILES=mesh so docker compose defaults to mesh topology without requiring --profile Deterministic mesh identity derivation: - Add derive-keys.py: pure Python tool (no deps) deriving nsec/npub from sha256(mesh-name|node-id) via secp256k1 and BIP-173 bech32 - generate-configs.sh and build.sh accept optional mesh-name argument; Docker node identities are derived while external nodes keep hardcoded keys from topology YAML Docker compose improvements: - Add mesh-public profile service definitions - build.sh now runs docker compose build automatically, providing a single command for the full binary+configs+images pipeline - Ping test script supports mesh-public topology Container services: - Add HTTP server on port 8000 (IPv6-bound) serving static page, accessible over FIPS overlay via npub.fips hostnames - Add rsync to container packages Documentation: - Comprehensive README update covering topology system, identity derivation, npubs.env, and container background services (SSH, iperf3, HTTP) with usage examples
72 lines
2.4 KiB
Bash
Executable File
72 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Build the FIPS binary, generate configs, and build Docker images.
|
|
# Supports cross-compilation from macOS to Linux using cargo-zigbuild.
|
|
# Usage: ./build.sh [topology] [mesh-name]
|
|
# topology: mesh, mesh-public, chain, etc. (default: mesh)
|
|
# mesh-name: optional; derives unique node identities via sha256(mesh-name|node-id)
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
DOCKER_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
# Topology to use (default: mesh)
|
|
TOPOLOGY="${1:-mesh}"
|
|
MESH_NAME="${2:-}"
|
|
|
|
# Find project root (directory containing Cargo.toml)
|
|
PROJECT_ROOT="$(cd "$DOCKER_DIR/../.." && pwd)"
|
|
if [ ! -f "$PROJECT_ROOT/Cargo.toml" ]; then
|
|
echo "Error: Cannot find Cargo.toml at $PROJECT_ROOT" >&2
|
|
echo "Expected layout: <project-root>/examples/docker-network/scripts/build.sh" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Using topology: $TOPOLOGY"
|
|
|
|
# Detect host OS
|
|
UNAME_S=$(uname -s)
|
|
CARGO_TARGET="x86_64-unknown-linux-musl"
|
|
|
|
# Check for cross-compilation tooling on macOS
|
|
if [ "$UNAME_S" = "Darwin" ]; then
|
|
echo "Detected macOS host - using cross-compilation for Linux..."
|
|
|
|
# Check if cargo-zigbuild is installed
|
|
if ! command -v cargo-zigbuild &> /dev/null; then
|
|
echo "Error: cargo-zigbuild not found." >&2
|
|
echo "Please install it: cargo install cargo-zigbuild" >&2
|
|
echo "" >&2
|
|
echo "Or install zig directly: brew install zig" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Check if target is installed
|
|
if ! rustup target list --installed | grep -q "$CARGO_TARGET"; then
|
|
echo "Installing Rust target $CARGO_TARGET..."
|
|
rustup target add "$CARGO_TARGET"
|
|
fi
|
|
|
|
echo "Building FIPS for Linux (release) using cargo-zigbuild..."
|
|
cargo zigbuild --release --target "$CARGO_TARGET" --manifest-path="$PROJECT_ROOT/Cargo.toml"
|
|
|
|
echo "Copying binary to docker context..."
|
|
cp "$PROJECT_ROOT/target/$CARGO_TARGET/release/fips" "$DOCKER_DIR/fips"
|
|
else
|
|
# Native Linux build
|
|
echo "Building FIPS (release)..."
|
|
cargo build --release --manifest-path="$PROJECT_ROOT/Cargo.toml"
|
|
|
|
echo "Copying binary to docker context..."
|
|
cp "$PROJECT_ROOT/target/release/fips" "$DOCKER_DIR/fips"
|
|
fi
|
|
|
|
echo "Done. Binary at $DOCKER_DIR/fips"
|
|
echo ""
|
|
echo "Generating node configurations from templates..."
|
|
"$SCRIPT_DIR/generate-configs.sh" "$TOPOLOGY" $MESH_NAME
|
|
echo ""
|
|
echo "Building Docker images..."
|
|
docker compose --profile "$TOPOLOGY" build
|
|
echo ""
|
|
echo "Ready: docker compose --profile $TOPOLOGY up -d"
|