Skip to main content
Version: 0.2.x

image

Implementation details for image rule

Rules

oci_image

Build an OCI compatible container image.

It takes number of tar files as layers to create image filesystem. For incrementality, use more fine grained tar files to build up the filesystem.

oci_image(
tars = [
"rootfs.tar",
"appfs.tar",
"libc6.tar",
"passwd.tar",
]
)

To base an oci_image on another oci_image, the base attribute MAYBE used.

oci_image(
base = "//sys:base",
tars = [
"appfs.tar"
]
)

To combine env with environment variables from the base, bash style variable syntax MAYBE used.

oci_image(
name = "base",
env = {"PATH": "/usr/bin"}
)

oci_image(
name = "app",
base = ":base",
env = {"PATH": "/usr/local/bin:$PATH"}
)

Example usage (generated):

load("@contrib_rules_oci//oci/private:image.bzl", "oci_image")

oci_image(
# A unique name for this target.
name = "",
)

name

Required name.

A unique name for this target.

architecture

Optional string. Default: ""

The CPU architecture which the binaries in this image are built to run on. eg: arm64, arm, amd64, s390x. See $GOARCH documentation for possible values: https://go.dev/doc/install/source#environment

base

Optional label. Default: None

Label to an oci_image target to use as the base.

cmd

Optional list of strings. Default: []

Default arguments to the entrypoint of the container. These values act as defaults and may be replaced by any specified when creating a container.

entrypoint

Optional list of strings. Default: []

A list of arguments to use as the command to execute when the container starts. These values act as defaults and may be replaced by an entrypoint specified when creating a container.

env

Optional dictionary: String → String. Default: {}

Default values to the environment variables of the container. These values act as defaults and are merged with any specified when creating a container. Entries replace the base environment variables if any of the entries has conflicting keys. To merge entries with keys specified in the base, ${KEY} or $KEY syntax may be used.

os

Optional string. Default: ""

The name of the operating system which the image is built to run on. eg: linux, windows. See $GOOS documentation for possible values: https://go.dev/doc/install/source#environment

tars

Optional list of labels. Default: []

List of tar files to add to the image as layers.

user

Optional string. Default: ""

The username or UID which is a platform-specific structure that allows specific control over which user the process run as. This acts as a default value to use when the value is not specified when creating a container. For Linux based systems, all of the following are valid: user, uid, user:group, uid:gid, uid:group, user:gid. If group/gid is not specified, the default group and supplementary groups of the given user/uid in /etc/passwd from the container are applied.

variant

Optional string. Default: ""

The variant of the specified CPU architecture. eg: v6, v7, v8. See: https://github.com/opencontainers/image-spec/blob/main/image-index.md#platform-variants for more.

workdir

Optional string. Default: ""

Sets the current working directory of the entrypoint process in the container. This value acts as a default and may be replaced by a working directory specified when creating a container.