Building from Source
Complete guide to building Triage Warden.
Prerequisites
Rust
# Install Rust via rustup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Verify installation
rustc --version # Should be 1.75+
Python
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Verify installation
uv --version
System Dependencies
macOS
brew install openssl pkg-config
Ubuntu/Debian
sudo apt-get install build-essential pkg-config libssl-dev
Fedora
sudo dnf install gcc openssl-devel pkgconfig
Building
Debug Build
cargo build
Outputs:
target/debug/tw-apitarget/debug/tw-cli
Release Build
cargo build --release
Outputs:
target/release/tw-apitarget/release/tw-cli
Python Package
cd python
uv sync
uv build
PyO3 Bridge
The bridge is built automatically with cargo:
cd tw-bridge
cargo build --release
Build Options
Feature Flags
# Build with PostgreSQL support only
cargo build --no-default-features --features postgres
# Build with all features
cargo build --all-features
Cross-Compilation
# For Linux (from macOS)
rustup target add x86_64-unknown-linux-gnu
cargo build --release --target x86_64-unknown-linux-gnu
# For musl (static binary)
rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl
Docker Build
Build Image
docker build -t triage-warden .
Multi-Stage Dockerfile
# Builder stage
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/tw-api /usr/local/bin/
CMD ["tw-api"]
Verification
Run Tests
# Rust tests
cargo test
# Python tests
cd python && uv run pytest
# All tests
./scripts/test-all.sh
Linting
# Rust
cargo fmt --check
cargo clippy -- -D warnings
# Python
cd python
uv run ruff check
uv run black --check .
uv run mypy .
Smoke Test
# Start server
./target/release/tw-api &
# Health check
curl http://localhost:8080/api/health
# Stop server
kill %1
Troubleshooting
OpenSSL Errors
# macOS
export OPENSSL_DIR=$(brew --prefix openssl)
# Linux
export OPENSSL_DIR=/usr
PyO3 Build Issues
# Ensure Python is found
export PYO3_PYTHON=$(which python3)
# Clean and rebuild
cargo clean -p tw-bridge
cargo build -p tw-bridge
Out of Memory
# Reduce parallel jobs
cargo build -j 2