In an effort to provide a consolidated location for all my current and future bazel-related examples, I have created a new centralized location for that on GitHub: scasagrande/bazel-examples

The intention here is to provide something similar to the Aspect Build bazel-examples repository, where others can come and find reference implementations for various common tasks. Some examples might be fully runnable bazel modules, while some might be bazel-adjacent code. As I include more I will aim to make a short corresponding post here.

As of today, there are two included examples:

rustls-openssl-fips Link to heading

The goal for this example was to answer the common question of “how do I get openssl-sys to build under rules_rust?”, but to make a little more advanced by using this as a way to create an application that can use openssl with FIPS mode enabled.

This example shows how to:

  • Build a basic rustls application
  • Use openssl as our crypto provider
  • Bundle our application into an OCI image
  • Start our application with FIPS mode enabled

To get there, we use the following:

rdkafka-sys Link to heading

Building the rdkafka-sys crate is a little commonly requested by the community in the Bazel slack, but can be tricky to implement. So I have provided an example on how to:

  • Set up a basic rust project using crate rdkafka
  • Define a bazel-native build of librdkafka
  • Use crate annotations to correctly build crate rdkafka-sys

With that all defined, we can then run tests against a running kafka + zookeeper service.