ocipkg

crate docs.rs master

OCI Registry for package distribution.

Features

Examples

| Library type | Create package in Rust | Use package from Rust | |:-------------|:-----------------------|:----------------------| | static |examples/static/rust/lib | examples/static/rust/exe | | dynamic |examples/dynamic/rust/lib | examples/dynamic/rust/exe |

CLI tools

Install

bash cargo install --features=cli ocipkg@0.1.0-rc.0

ocipkg command

TBW

cargo-ocipkg command

A tool for creating and publishing container using library built by cargo build.

$ cargo ocipkg build --release Finished release [optimized] target(s) in 0.00s Creating oci-archive (/home/teramura/github.com/termoshtt/ocipkg/examples/dynamic/rust/lib/target/release/ocipkg_dd0c7a812fd0fcbc.tar)

The filename is in form of ocipkg_{{ hash }}.tar, and this hash is calculated from image name and Cargo.toml.

Container image name is determined using git commit hash as {{ registry }}:$(git rev-parse HEAD --short) where registry name is set by Cargo.toml:

toml [package.metadata.ocipkg] registry = "ghcr.io/termoshtt/ocipkg/dynamic/rust"

This container can be published by cargo-ocipkg publish:

$ cargo ocipkg publish --release Publish container (ghcr.io/termoshtt/ocipkg/dynamic/rust:be7f108)

Why ocipkg?

I have determined to start this project while writing FFI crate in Rust. The problem is "how to get a share/static library linked to FFI crate". This is the problem bothered me and prevent from creating portable C++ library.

We have three options:

  1. Use library in the system
  2. Get source code from the internet, and build and link them
  3. Get compiled library from the internet on build time

ocipkg focuses on 3., i.e. helping distributing binary compiled by the developer through OCI registry.

Links

Open Container Initiative (OCI) is a project under Linux Foundation.

The idea that distribute binary files (not a system image) using OCI registry is based on ORAS.

Similar projects trying to distribute packages using OCI registries:

License

© 2020 Toshiki Teramura (@termoshtt)

This project is licensed under either of

at your option.