Understanding the Build Process
Anubis embeds JavaScript and CSS assets directly into the Go binary. This means you must build assets before any Go build or test operation.Build Order
- Generate code from templ templates and other generators
- Build frontend assets (JavaScript and CSS)
- Compress assets (gzip, zstd, brotli variants)
- Build Go binary with embedded assets
Build Assets
Build all frontend assets (required before any Go build):go generate ./...- Generates Go code from.templfiles./web/build.sh- Builds and bundles JavaScript fromweb/js/./xess/build.sh- Builds CSS from the xess framework- Creates compressed variants (
.gz,.zst,.br) for all static assets
Build the Binary
Build the complete Anubis binary:npm run assets followed by:
./var/anubis.
Run Locally
Run Anubis in development mode:--use-remote-addressflag (uses the client’s real IP)--target http://localhost:3000(proxies to local dev server)
Available Build Scripts
Frompackage.json:
| Script | Command | Description |
|---|---|---|
npm run assets | go generate ./... && ./web/build.sh && ./xess/build.sh | Build all frontend assets |
npm run build | npm run assets && go build -o ./var/anubis ./cmd/anubis | Full production build |
npm run dev | npm run assets && go run ./cmd/anubis --use-remote-address --target http://localhost:3000 | Run in dev mode |
npm run container | npm run assets && go run ./cmd/containerbuild | Build container image |
npm run format | prettier -w . && go run goimports -w . | Format all code |
Build Artifacts
After building, you’ll find:./var/anubis- Main binaryweb/static/- Bundled JavaScript and CSS with compressed variants- Generated Go files from
.templtemplates
Code Generation
Anubis usesgo generate for:
- Templ templates:
web/*.templfiles generate Go code - Stringer: Enum types generate String() methods
Generated files are committed to the repository, so you typically only need to regenerate after modifying
.templ files or enum definitions.Troubleshooting
Assets Not Found at Runtime
If you see errors about missing assets:- Ensure you ran
npm run assetsbefore building - Check that
web/static/contains.jsand.cssfiles - Rebuild completely:
npm run build