Building Bifrost
Building Bifrost
Section titled “Building Bifrost”This guide covers building Bifrost from source for various platforms.
Prerequisites
Section titled “Prerequisites”Required Software
Section titled “Required Software”| Software | Version | Purpose |
|---|---|---|
| Go | 1.22+ | Compiler |
| Node.js | 18+ | Web UI build |
| npm | 9+ | Package manager |
| Make | any | Build automation |
| Git | any | Version control |
Installing Prerequisites
Section titled “Installing Prerequisites”macOS:
brew install go node git makeUbuntu/Debian:
sudo apt updatesudo apt install golang nodejs npm git makeFedora:
sudo dnf install golang nodejs npm git makeWindows (with Chocolatey):
choco install golang nodejs git makeVerify Installation
Section titled “Verify Installation”go version # Should show go1.22+node --version # Should show v18+npm --version # Should show 9+make --versionQuick Start
Section titled “Quick Start”# Clone the repositorygit clone https://github.com/rennerdo30/bifrost-proxy.gitcd bifrost-proxy
# Build everything (server + client + web UI)make build
# Binaries are in bin/ls bin/# bifrost-server bifrost-clientBuild Targets
Section titled “Build Targets”Development Builds
Section titled “Development Builds”# Build both server and client (includes web UI)make build
# Build server onlymake build-server
# Build client onlymake build-client
# Build stripped binaries (30-40% smaller, no debug info)make build-strippedCross-Platform Builds
Section titled “Cross-Platform Builds”# Build for all platforms (Linux, macOS, Windows)make build-all
# Build for specific platformmake build-linuxmake build-darwinmake build-windowsOpenWrt / Embedded Builds
Section titled “OpenWrt / Embedded Builds”# Build for all OpenWrt architecturesmake build-openwrt
# Build for MIPS only (big-endian + little-endian)make build-openwrt-mips
# Build for ARM only (v6, v7, arm64)make build-openwrt-armOutput Directories
Section titled “Output Directories”| Directory | Contents |
|---|---|
bin/ | Development binaries (current platform) |
dist/ | Cross-compiled release binaries |
Build Options
Section titled “Build Options”Environment Variables
Section titled “Environment Variables”| Variable | Default | Description |
|---|---|---|
VERSION | git tag | Version string embedded in binary |
COMMIT | git sha | Commit hash embedded in binary |
CGO_ENABLED | 0 | Disable CGO for static binaries |
Example with custom version:
VERSION=1.0.0-custom make buildBuild Flags
Section titled “Build Flags”The Makefile uses these Go build flags:
# Standard build-ldflags "-X .../version.Version=... -X .../version.GitCommit=..."
# Stripped build (smaller binary)-ldflags "-s -w -X .../version.Version=... -X .../version.GitCommit=..."-sstrips the symbol table-wstrips DWARF debugging info
Manual Build Commands
Section titled “Manual Build Commands”If you prefer not to use Make:
Standard Build
Section titled “Standard Build”# Build web UI firstcd web/server && npm install && npm run build && cd ../..cd web/client && npm install && npm run build && cd ../..
# Build Go binariesgo build -o bin/bifrost-server ./cmd/servergo build -o bin/bifrost-client ./cmd/clientCross-Compilation
Section titled “Cross-Compilation”# Linux AMD64GOOS=linux GOARCH=amd64 go build -o dist/bifrost-server-linux-amd64 ./cmd/server
# macOS ARM64 (Apple Silicon)GOOS=darwin GOARCH=arm64 go build -o dist/bifrost-server-darwin-arm64 ./cmd/server
# Windows AMD64GOOS=windows GOARCH=amd64 go build -o dist/bifrost-server-windows-amd64.exe ./cmd/server
# OpenWrt MIPS (with softfloat)CGO_ENABLED=0 GOOS=linux GOARCH=mipsle GOMIPS=softfloat \ go build -ldflags "-s -w" -o dist/bifrost-server-linux-mipsle ./cmd/server
# OpenWrt ARM v7CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 \ go build -ldflags "-s -w" -o dist/bifrost-server-linux-arm7 ./cmd/serverArchitecture Reference
Section titled “Architecture Reference”Supported Platforms
Section titled “Supported Platforms”| OS | Architecture | Binary Suffix | Notes |
|---|---|---|---|
| Linux | amd64 | -linux-amd64 | Most servers/desktops |
| Linux | arm64 | -linux-arm64 | Raspberry Pi 3+, modern ARM |
| Linux | arm (v6) | -linux-arm6 | Raspberry Pi 1, Pi Zero |
| Linux | arm (v7) | -linux-arm7 | Raspberry Pi 2, many routers |
| Linux | mips | -linux-mips | OpenWrt routers (big-endian) |
| Linux | mipsle | -linux-mipsle | OpenWrt routers (little-endian) |
| macOS | amd64 | -darwin-amd64 | Intel Macs |
| macOS | arm64 | -darwin-arm64 | Apple Silicon (M1/M2/M3) |
| Windows | amd64 | -windows-amd64.exe | Most Windows PCs |
OpenWrt Architecture Detection
Section titled “OpenWrt Architecture Detection”To determine your router’s architecture:
# On the routercat /proc/cpuinfo | head -10
# Or check OpenWrt infocat /etc/openwrt_releaseuname -muname -m Output | Binary to Use |
|---|---|
mips | bifrost-server-linux-mips |
mipsel | bifrost-server-linux-mipsle |
armv6l | bifrost-server-linux-arm6 |
armv7l | bifrost-server-linux-arm7 |
aarch64 | bifrost-server-linux-arm64-openwrt |
Web UI Build
Section titled “Web UI Build”The web UI is built with Vite and embedded into the Go binary.
Build Commands
Section titled “Build Commands”# Install dependenciesmake web-install
# Build both UIsmake web-build
# Build server UI onlymake web-build-server
# Build client UI onlymake web-build-client
# Development server (hot reload)make web-dev # Server UImake web-dev-client # Client UIWeb UI Source
Section titled “Web UI Source”| Path | Description |
|---|---|
web/server/ | Server dashboard UI |
web/client/ | Client debug/traffic UI |
Embedded Static Files
Section titled “Embedded Static Files”Built UI files are copied to:
internal/api/server/static/(server)internal/api/client/static/(client)
These are embedded using Go’s //go:embed directive.
Testing
Section titled “Testing”# Run all testsmake test
# Run tests with coveragemake test-coverage
# Run integration tests (requires more setup)make test-integration
# View coverage reportopen coverage.htmlLinting
Section titled “Linting”# Run lintermake lint
# Format codemake fmtRequires golangci-lint:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestDocker Build
Section titled “Docker Build”# Build Docker imagesmake docker-build
# Build and start with docker-composemake docker-deploy
# Rebuild with no cachemake docker-rebuild-cleanRelease Process
Section titled “Release Process”Releases are automated via GitHub Actions:
- Nightly builds: Triggered on every push to
master/main - Tagged releases: Triggered when a tag like
v1.0.0is pushed
Creating a Release
Section titled “Creating a Release”# Tag a releasegit tag v1.0.0git push origin v1.0.0This triggers:
- GoReleaser builds all platforms (including OpenWrt)
- Creates GitHub release with binaries
- Builds and pushes Docker images
Manual Release Build
Section titled “Manual Release Build”# Install GoReleasergo install github.com/goreleaser/goreleaser@latest
# Build without releasing (dry run)goreleaser release --snapshot --clean
# Check dist/ for outputls dist/Troubleshooting
Section titled “Troubleshooting””go: command not found”
Section titled “”go: command not found””Ensure Go is in your PATH:
export PATH=$PATH:/usr/local/go/binexport PATH=$PATH:$(go env GOPATH)/bin“npm: command not found”
Section titled ““npm: command not found””Install Node.js:
# macOSbrew install node
# Ubuntucurl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -sudo apt install -y nodejsWeb UI not updating
Section titled “Web UI not updating”The web UI is embedded at build time. Rebuild to see changes:
make web-buildmake buildBinary too large
Section titled “Binary too large”Use stripped builds:
make build-stripped# ormake build-openwrt # OpenWrt builds are always strippedCross-compilation fails
Section titled “Cross-compilation fails”Ensure CGO is disabled for cross-compilation:
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build ...MIPS build fails with “softfloat required”
Section titled “MIPS build fails with “softfloat required””Some MIPS routers lack hardware floating-point. Use:
GOMIPS=softfloat go build ...The make build-openwrt-mips target includes this automatically.
CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions
Section titled “GitHub Actions”The project includes these workflows:
| Workflow | Trigger | Purpose |
|---|---|---|
ci.yml | PR, push | Tests, linting |
nightly.yml | push to master | Nightly builds |
release.yml | tag v* | Official releases |
docs.yml | docs changes | Documentation site |
Required Secrets
Section titled “Required Secrets”For releases:
GITHUB_TOKEN(automatic)
For Docker registry (optional):
- Container registry credentials (uses GHCR by default)
Binary Size Reference
Section titled “Binary Size Reference”Approximate sizes after stripping:
| Platform | Server | Client |
|---|---|---|
| Linux amd64 | ~15 MB | ~12 MB |
| Linux arm64 | ~14 MB | ~11 MB |
| OpenWrt MIPS | ~12 MB | ~10 MB |
| OpenWrt ARM7 | ~11 MB | ~9 MB |
| macOS arm64 | ~15 MB | ~12 MB |
| Windows amd64 | ~16 MB | ~13 MB |
Sizes include embedded web UI (~400KB compressed)