Skip to content

feat: add build flags for reduced binary size#737

Merged
rsdmike merged 11 commits intodevice-management-toolkit:mainfrom
nmgaston:featAddBuildFlags
Jan 6, 2026
Merged

feat: add build flags for reduced binary size#737
rsdmike merged 11 commits intodevice-management-toolkit:mainfrom
nmgaston:featAddBuildFlags

Conversation

@nmgaston
Copy link
Copy Markdown
Contributor

@nmgaston nmgaston commented Dec 20, 2025

Build Variants

  • noui: Excludes web UI (~100MB reduction when UI assets embedded)

Binary Sizes (with UI assets embedded)

  • Full (with UI): ~160MB unstripped, ~100MB stripped
  • Headless (no UI): ~60MB unstripped, ~42MB stripped

Key Features

  • Fully static binaries using CGO_ENABLED=0 with pure Go dependencies (modernc.org/sqlite, jackc/pgx/v5)
  • Minimal Docker images using FROM scratch (no OS packages, ~0MB base)
  • Conditional compilation: features automatically included/excluded based on build tags

Release Artifacts
Each platform (Linux, Windows, macOS) produces 3 binaries:

  1. Full: SQLite + UI support
  2. Headless: SQLite, no UI

CI/CD Updates

  • All workflows build and test multiple variants with proper CGO settings

@nmgaston nmgaston marked this pull request as ready for review January 6, 2026 00:29
@nmgaston nmgaston requested a review from rsdmike January 6, 2026 00:29
@nmgaston
Copy link
Copy Markdown
Contributor Author

nmgaston commented Jan 6, 2026

@rsdmike - Since there isn't a size advantage to the nosqlite flag, I question if we should include it. Found that we actually don't need CGO_ENABLED=1 in any of the build cases, which I think is what we were trying to do with that particular flag. It seems like it's adding unneeded complexity without any real advantage. Major advantage to the 'noui' flag. Thoughts?

@nmgaston nmgaston marked this pull request as draft January 6, 2026 00:56
@nmgaston nmgaston marked this pull request as ready for review January 6, 2026 01:57
@rsdmike
Copy link
Copy Markdown
Member

rsdmike commented Jan 6, 2026

@rsdmike - Since there isn't a size advantage to the nosqlite flag, I question if we should include it. Found that we actually don't need CGO_ENABLED=1 in any of the build cases, which I think is what we were trying to do with that particular flag. It seems like it's adding unneeded complexity without any real advantage. Major advantage to the 'noui' flag. Thoughts?

I agree, if it doesnt add value, lets not complicate the build. I say lets get rid of it. For history, I think the CGO requirement originally came from https://github.com/99designs/keyring which used the C Bindings for the keyring. Recently we switched to https://github.com/zalando/go-keyring which is pure go. Similar story for sqlite (used originally the CGO version then the pure go version). So now that we are pure go, we can greatly simplify the CI/CD workflow as we no longer need to coordinate the build across multiple OSes. However, we'll save that optimization I think for a different PR and just remove the nosqlite in this one.

FWIW, I did see about a 3MB reduction with removing SQLite, but still not materially different to warrant the extra build complexity.

image

Thank you for doing this!

@nmgaston nmgaston marked this pull request as draft January 6, 2026 17:30
@nmgaston nmgaston marked this pull request as ready for review January 6, 2026 20:00
@rsdmike rsdmike merged commit 3940981 into device-management-toolkit:main Jan 6, 2026
18 checks passed
@RosieAMT
Copy link
Copy Markdown

RosieAMT commented Jan 6, 2026

🎉 This PR is included in version 1.18.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nmgaston nmgaston deleted the featAddBuildFlags branch January 6, 2026 23:12
sudhir-intc pushed a commit that referenced this pull request Feb 17, 2026
* feat: add build flags for reduced binary size

* feat: support the 3 build types

* fix: mismatch of CGO_ENABLED flag

* fix: use CGO_ENABLED=0 and scratch base for all builds

* revert: remove changes regarding nosqlite tag since benefit was minimal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants