Skip to content

Commit

Permalink
cargo: Add a mostly-static build configuration
Browse files Browse the repository at this point in the history
Add a "static" feature flag that enables building rusqlite with the
"bundled" feature (via the matrix-sdk "bundled-sqlite" one) and using
rustls instead of openssl (via the matrix-sdk "rustls-tls" feature).
This results in a binary that depends only on the C library (libm, libc)
and libgcc:

  % cargo build --release --no-default-features --features static
  ...
  % ls -lh target/release/hebbot
  -rwxr-xr-x 1 aperez aperez 32M oct  9 21:46 target/release/hebbot*
  % lddtree target/release/hebbot
  target/release/hebbot (interpreter => /lib64/ld-linux-x86-64.so.2)
      libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
      libm.so.6 => /usr/lib/libm.so.6
      libc.so.6 => /usr/lib/libc.so.6
      ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
  %

This allows running Hebbot from tiny containers, for example using the
"static-debian12" provided by the Distroless project [1], which itself
takes only about 2 MiB of space.

[1] https://github.com/GoogleContainerTools/distroless/
  • Loading branch information
aperezdc committed Oct 9, 2024
1 parent 4c7152a commit b57ef43
Show file tree
Hide file tree
Showing 2 changed files with 215 additions and 26 deletions.
Loading

0 comments on commit b57ef43

Please sign in to comment.