/oci-rules

buck2 oci rules

Primary LanguageStarlarkApache License 2.0Apache-2.0

oci-rules

Buck2 rules for the Open Containers Initiative image format.

Installation

Add this repo as an external cell in your projects .buckconfig

[cells]
  # there will be other cells already
  oci = oci

[external_cells]
  # there may be other external cells already
  oci = git

[external_cell_oci]
  git_origin = https://github.com/benbrittain/oci-rules.git
  commit_hash = 7cda0ad213b2108f50beb756697f3c5435ad2c56

Configuring the toolchain

The OCI rules depend on a container manipulation tool called crane. You must define the oci_toolchain rule in your //toolchains cell.

Example:

load("@oci//oci:toolchain.bzl", "oci_toolchain", "download_crane_binary")

# Optional helper macro for fetching the crane binary based on platform arch
download_crane_binary(                      
    name = "crane",                         
    version = "0.19.1",                     
)

# Register the mandatory toolchain
oci_toolchain(                                     
    name = "oci",                                  
    crane = ":crane",                              
    visibility = ["PUBLIC"],                       
)                                                  

Documentation

TODO: Render documentation from starlark here

Example

$ buckle build //tests:image --out - | podman load
$ podman run -it --rm localhost:61978/image.tar:latest