Package: pants-backend-oci
OCI backend for PantsWarningThis plugin is in development. No stability is guaranteed! Contributions welcome.This is a backend implementing support for building OCI images in pants; running them, and publishing them to container registries. To do this, this plugin uses three different tools:umocifor manipulating OCI imagesruncfor exeuctionskopeofor pulling and pushing imagesPlanned and missing featuresCurrently there's no support for pulling tags, as that would break determinismMulti-platform SHA/.sig is untested/unsupportedskopeo doesn't support MacOS, preventing pulling and pushing images.No "in-container" build stepsTargetsThere's six targets currently implemented, of which five are generic:oci_pull_imageoci_pull_imagesoci_image_buildoci_image_emptyoci_build_layerAnd one with some special language semantics:oci_python_image- this is the same asoci_image_build, but will prefer to set the entrypoint to.pexfiles.oci_pull_imagePull an image from a repository with a specific digest.oci_pull_image(name="base-python",repository="docker.io/library/python",sha="b78b777208be08edd8f297035cdfbacddb45170ad778fd643c792ee045187e39")ArgumentMeaningDefault valuenameThe target nameSame as any other target, which is the directory namerepositoryFully qualified repository nameRequiredshaThe digest of the image, minus the @sha: prefix.RequiredanonymousWhether to pull the image anonymously.falsedecsriptionA description of the targettagsList of tags[]oci_pull_imagesPull multiple shas for an image, generating a target for each. In the below example, we'd get the targets:python#slimand:python#buster.oci_pull_image(name="python",repository="docker.io/library/python",variants={"slim":"f8fbb2370c6314c806b2ddbec8d94375987e16bc122379bef979c6fc5e962920","buster":"97c123c899c8c9ca46248f4002ec4173322e0a1086b386efefac163c64967ba2"})ArgumentMeaningDefault valuenameThe target nameSame as any other target, which is the directory namerepositoryFully qualified repository nameRequiredvariantsDictionary with local tags to the remote shaRequiredanonymousWhether to pull the image anonymouslyfalsedecsriptionA description of the targettagsList of tags[]oci_build_imageBuild an image with the provided packages embedded.oci_image_build(name="my-server",base=":python#slim",repository="my-registry.example.com/a-namespace/an-image",tag="latest",packages=[":my_pex"])ArgumentMeaningDefault valuenameThe target nameSame as any other target, which is the directory namebaseThe base image to use. Matches theFROMdirective in a DockerfileRequiredpackagesPackaged targets to include. The first element will be used as the entrypoint.[]repositoryFully qualified repository nameRequired when publishingtagRemote tag to useRequired when publishingdecsriptionA description of the targettagsList of tags[]oci_python_imageBuild a Python image with the provided packages embedded.oci_python_image(name="my-server",base=":python#slim",repository="my-registry.example.com/a-namespace/an-image",main="/app/server/start.py",tag="latest",packages=[":my_pex"])ArgumentMeaningDefault valuenameThe target nameSame as any other target, which is the directory namebaseThe base image to use. Matches theFROMdirective in a DockerfileRequiredpackagesPackaged targets to include. The first element will be used as the entrypoint.[]python_mainThe main file to runThe last.pexin the dependency listrepositoryFully qualified repository nameRequired when publishingtagRemote tag to useRequired when publishingdecsriptionA description of the targettagsList of tags[]oci_image_emptyAn empty base image with no contents at all. This is declared as//:emptyautomatically, but you can use this to create new targets.oci_image_empty(name="empty",)ArgumentMeaningDefault valuenameThe target nameSame as any other target, which is the directory namedecsriptionA description of the targettagsList of tags[]oci_build_layerRun an image command, and capture the configured output into a layer artifact, that can be injected into other images. This matches theCOPY --fromworkflows.oci_build_layer(
name="layer"
base=[":rust-1-70"],
packages=[":files"],
env=['RUSTC_OPTS=...'],
command=['cd /my-package && cargo build --release'],
outputs=['/my-package/target/release/my-package'],
)| Argument      | Meaning                                                                        | Default value                                          |
|---------------|--------------------------------------------------------------------------------|--------------------------------------------------------|
| `name`        | The target name                                                                | Same as any other target, which is the directory name  |
| `packages`    | Packaged targets to include. The first element will be used as the entrypoint. | `[]`                                                   |
| `env`         | Environment variables to set. Does not support interpolation.                  | `[]`                                                   |
| `outputs`     | Paths to capture into the built layer.                                         | `[]`                                                   |
| `exclude`     | Globs to not include in the output.                                            | `[]`                                                   |
| `decsription` | A description of the target                                                    |                                                        |
| `output_path` | The output path during `pants package`                                         | A variant generated from the target name and directory |
| `tags`        | List of tags                                                                   | `[]`                                                   |