ocibuild_rebar3 (ocibuild v0.10.4)
View SourceRebar3 provider for building OCI container images from releases.
Usage
rebar3 release
rebar3 ocibuild -t myapp:1.0.0Or push directly to a registry:
rebar3 ocibuild -t myapp:1.0.0 --push ghcr.io/myorgOptions
-t, --tag- Image tag (e.g., myapp:1.0.0). Can be specified multiple times.-o, --output- Output tarball path (default: <tag>.tar.gz)-p, --push- Push to registry (e.g., ghcr.io/myorg)-a, --annotation- Add manifest annotation KEY=VALUE (repeatable)--base- Override base image--release- Release name (if multiple configured)--compression- Layer compression: gzip, zstd, or auto (default: auto)
Configuration
Add to your rebar.config:
{ocibuild, [
{base_image, "debian:stable-slim"},
{workdir, "/app"},
{env, #{~"LANG" => ~"C.UTF-8"}},
{expose, [8080]},
{labels, #{}},
{annotations, #{<<"org.opencontainers.image.description">> => <<"My awesome application">>}},
{tag, ["myapp:1.0.0", "myapp:latest"]}, % or a single string: "myapp:1.0.0"
{compression, auto} % gzip, zstd, or auto (zstd on OTP 28+, gzip on OTP 27)
]}.Authentication
Set environment variables for registry authentication:
For pushing to registry:
export OCIBUILD_PUSH_USERNAME="user"
export OCIBUILD_PUSH_PASSWORD="pass"For pulling private base images (optional, anonymous pull used if unset):
export OCIBUILD_PULL_USERNAME="user"
export OCIBUILD_PULL_PASSWORD="pass"
Summary
Functions
Print a message to the console using rebar_api.
Execute the provider - build OCI image from release.
Log an error message using rebar_api.
Find release directory from rebar state.
Format error messages for display.
Get application version from rebar state.
Get normalized configuration from rebar state.
Get dependencies from rebar.lock file.
Log an informational message using rebar_api.
Initialize the provider and register CLI options.
Functions
Print a message to the console using rebar_api.
-spec do(rebar_state:t()) -> {ok, rebar_state:t()} | {error, term()}.
Execute the provider - build OCI image from release.
Log an error message using rebar_api.
-spec find_release(rebar_state:t(), map()) -> {ok, binary(), file:filename()} | {error, term()}.
Find release directory from rebar state.
Format error messages for display.
-spec get_app_version(rebar_state:t()) -> binary() | undefined.
Get application version from rebar state.
Extracts the version from the first release in the relx configuration.
This is used for the org.opencontainers.image.version annotation.
-spec get_config(rebar_state:t()) -> ocibuild_adapter:config().
Get normalized configuration from rebar state.
-spec get_dependencies(rebar_state:t()) -> {ok, [#{name := binary(), version := binary(), source := binary()}]} | {error, term()}.
Get dependencies from rebar.lock file.
Parses the rebar.lock file to extract dependency information including name, version, and source (hex or git). This data is used for:
- Smart layer classification (dependencies vs application code)
- Future SBOM generation
Supports both old format (list only) and new format (version tuple + list).
Log an informational message using rebar_api.
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
Initialize the provider and register CLI options.