Crates.io | oci-tar-builder |
lib.rs | oci-tar-builder |
version | 0.4.0 |
source | src |
created_at | 2024-03-20 22:44:01.88607 |
updated_at | 2024-03-20 22:44:01.88607 |
description | Library that can be used to build OCI tar archives |
homepage | https://github.com/containerd/runwasi |
repository | https://github.com/containerd/runwasi |
max_upload_size | |
id | 1181034 |
size | 36,547 |
This is a library that can be used to build OCI tar archives. It is used by the wasi-demo-app
crate to build the OCI tar archive that is used to run the demo app.
The current implementation is to support encapsulating the wasi-demo-app
wasm module as an OCI tar.
We welcome contributions to this to make it more robust, useful, and generally better.
The library is currently not published to crates.io, so you will need to add the following to your Cargo.toml
:
[dependencies]
oci-tar-builder = { git = "https://github.com/containerd/runwasi.git" }
See wasi-demo-app build script for an example.
There is an experimental executable that uses the library and can package a wasm module as an OCI image with wasm layers. See the OCI WASM in containerd for more information.
To generate the package and import to a registry using a tool such as regctl:
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasi/debug/wasi-demo-app.wasm -o ./dist/img-oci.tar
regctl image import localhost:5000/wasi-demo-oci:latest ./dist/img-oci.tar
View the manifest created, notice that the media types for the layers are application/vnd.bytecodealliance.wasm.component.layer.v0+wasm
which are subject to change.
Name: localhost:5000/wasi-demo-oci:latest
MediaType: application/vnd.oci.image.manifest.v1+json
Digest: sha256:6c48b431d29a1ea1ece13fa50e9f33e4d164e07f6a501dbed668aed947002c5c
Annotations:
io.containerd.image.name: ghcr.io/containerd/runwasi/wasi-demo-oci:latest
org.opencontainers.image.ref.name: latest
Total Size: 2.590MB
Config:
Digest: sha256:beb7483682ae4ec45d02cd7cee8ee733f8dc610cb7e91070dc8f10567365bdd7
MediaType: application/vnd.oci.image.config.v1+json
Size: 138B
Layers:
Digest: sha256:656e978ae0c37156a6abe06052a588e5c700346650765859981ebd2089cffd42
MediaType: application/vnd.bytecodealliance.wasm.component.layer.v0+wasm
Size: 2.590MB
See the OCI Image Spec for more information on the OCI tar format.
In order to be compatible with Docker, since Docker does not currently support the OCI format, this also includes a manifest.json
file at the root of the tar that describes the image in a way that Docker can import it.