Skip to main content

OCI backend for Pants

This release targets Pants 2.31.0. Install it with pants-backend-oci==0.10.0 in [GLOBAL].plugins in pants.toml.

PyPI

Warning This 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:

  • umoci for manipulating OCI images
  • runc for exeuction
  • skopeo for pulling and pushing images

Tool versions

The defaults are umoci v0.6.0, Skopeo v1.24.1, and runc v1.5.2. umoci uses official Linux binaries and matching macOS builds from tgolsson/umoci-binary. Skopeo binaries come from lework/skopeo-binary, since the Skopeo project does not publish standalone binaries. Both tools cover Linux/macOS on x86-64 and ARM64. runc is Linux-only, with v1.4.3, v1.3.6, and v1.2.9 also recorded. Use [umoci].version, [skopeo].version, or [runc].version to select another recorded version. Stable umoci now supports macOS without selecting the legacy pinned nightly version.

Kustomize injection publishes locally built image dependencies to their configured registry before inserting their image digest. An omitted registry tag defaults to latest.

Planned and missing features

  • Currently there's no support for pulling tags, as that would break determinism
  • Multi-platform SHA/.sig is untested/unsupported
  • Container execution and in-container build steps require Linux (runc).

Targets

There's six targets currently implemented, of which five are generic:

  • oci_pull_image
  • oci_pull_images
  • oci_image_build
  • oci_image_empty
  • oci_build_layer

And one with some special language semantics:

  • oci_python_image - this is the same as oci_image_build, but will prefer to set the entrypoint to .pex files.

oci_pull_image

Pull an image from a repository with a specific digest.

oci_pull_image(
    name="base-python",
    repository="docker.io/library/python",
    sha="b78b777208be08edd8f297035cdfbacddb45170ad778fd643c792ee045187e39"
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
repository Fully qualified repository name Required
sha The digest of the image, minus the @sha: prefix. Required
anonymous Whether to pull the image anonymously. false
decsription A description of the target
tags List of tags []

oci_pull_images

Pull multiple shas for an image, generating a target for each. In the below example, we'd get the targets :python#slim and :python#buster.

oci_pull_image(
    name="python",
    repository="docker.io/library/python",
    variants={
       "slim": "f8fbb2370c6314c806b2ddbec8d94375987e16bc122379bef979c6fc5e962920",
       "buster": "97c123c899c8c9ca46248f4002ec4173322e0a1086b386efefac163c64967ba2"
    }
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
repository Fully qualified repository name Required
variants Dictionary with local tags to the remote sha Required
anonymous Whether to pull the image anonymously false
decsription A description of the target
tags List of tags []

oci_build_image

Build 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"]
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
base The base image to use. Matches the FROM directive in a Dockerfile Required
packages Packaged targets to include. The first element will be used as the entrypoint. []
repository Fully qualified repository name Required when publishing
tag Remote tag to use Required when publishing
decsription A description of the target
tags List of tags []

oci_python_image

Build 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"]
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
base The base image to use. Matches the FROM directive in a Dockerfile Required
packages Packaged targets to include. The first element will be used as the entrypoint. []
python_main The main file to run The last .pex in the dependency list
repository Fully qualified repository name Required when publishing
tag Remote tag to use Required when publishing
decsription A description of the target
tags List of tags []

oci_image_empty

An empty base image with no contents at all. This is declared as //:empty automatically, but you can use this to create new targets.

oci_image_empty(
    name="empty",
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
decsription A description of the target
tags List of tags []

oci_extract

Extract one or more files from another container image.

oci_extract(
    name="my-app-binary"
	base=[":some-app"],
	outputs=['/usr/bin/local/the-app'],
)
Argument Meaning Default value
name The target name Same as any other target, which is the directory name
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 []

oci_build_layer

Run a command in an image, and capture the configured output into a layer artifact, that can be injected into other images. This matches the COPY --from workflows.

oci_build_layer(
    name="layer"
	base=[":rust-1-70"],
    packages=[":files"],
    env=['RUSTC_OPTS=...'],
	commands=['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
commands The commands to execute in the container []
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 []

Metadata

Release files for pants-backend-oci 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pants-backend-oci 0.10.0
File Size Uploaded
pants_backend_oci-0.10.0.tar.gz 32.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pants-backend-oci 0.10.0
File Interpreter ABI Platform
pants_backend_oci-0.10.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 80.5 kB

Release files / pants_backend_oci-0.10.0.tar.gz

Download URL pants_backend_oci-0.10.0.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
339a484515ef1dbeff4b24a6255ce6dff153fcd0769f0175c6d786cc27f3d6d3
BLAKE2b-256 checksum
How to use checksums
dd7553882df7f48df8fc6d78759a898c16a1f18229884df14a009c807e9540a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release files / pants_backend_oci-0.10.0-py2.py3-none-any.whl

Download URL pants_backend_oci-0.10.0-py2.py3-none-any.whl
Size 48.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2ba9649687cce8f7825a299a46e5c7636e96a421fe4b025c06f2681e1aa05e07
BLAKE2b-256 checksum
How to use checksums
64c2274523f518a9899491122c9853732de7f671ff82feaf2f3a25370ba9cd27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page