Skip to content

About

BuildX rules for Bazel

Resources

Code of conduct

Contributing

Stars

21 stars

Watchers

2 watching

Forks

Repository files navigation

Bazel rules for BuildX

Bazel rules for buildx so you can use your existing Dockerfiles with Bazel.

Why would you want this?

rules_oci approaches container definitions from the perspective that container images are composites of layers which need to be assembled, and which can be assembled without using a container runtime. This works well for distroless-style images which have few or no "system" dependencies, and which can be described in terms of layering Bazel-defined build products into container images.

Treating OCI images as "just a stack of tarballs" struggles with building more conventional system-image style Docker containers. It's common to see Dockerfiles which manage dependencies via RUN apt-get install or RUN curl|bash and such which are difficult to model when assembling containers from layers of assets.

This tool provides a bridge for teams with existing Dockerfiles. By leveraging BuildX, which allows for non-hermetic behavior (meaning builds might not be perfectly reproducible), it becomes possible to drive existing not-yet-hermetic container builds with Bazel and to work towards more hermetic container definitions by treating BuildX defined images as bases which can be built on with more hermetic practices.

Installation

Follow instructions from the release you wish to use: https://github.com/aspect-build/rules_buildx/releases

Requirements

  • A working Docker runtime on the execution environment.1 BuildX does not work with other container runtimes such as podman.
  • Network access for buildx_build actions.2

Usage

See the API documentation, the end-to-end test in e2e/smoke, and the examples:

Resources

Support

This ruleset is community-supported with help from Aspect. We review pull requests and fix critical issues when we can, but we cannot promise timelines. Contributions are welcome.

Footnotes

  1. This makes rules_buildx a poor fit for containerized build environments, which would need Docker-in-Docker. ↩

  2. Base images don't have to come from a registry: buildx_context_oci_layout can supply an OCI layout fetched by Bazel, such as one from oci.pull in rules_oci. See e2e/smoke. ↩

About

BuildX rules for Bazel

Resources

Code of conduct

Contributing

Stars

21 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages