-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add OCI Image Specs support #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
themoriarti
wants to merge
11
commits into
zombocoder:main
Choose a base branch
from
themoriarti:oci-image-specs-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ee14fb8
Add OCI Image Specs support
themoriarti 8271c4e
feat: implement OCI image specs support with dynamic arch/OS detection
themoriarti 2f18001
Merge branch 'zombocoder:main' into oci-image-specs-support
themoriarti b57475b
style: apply clang-format to all source files
themoriarti 717ec88
Fix OCI support
themoriarti 319faf2
Merge branch 'zombocoder:main' into oci-image-specs-support
themoriarti 49ed931
Apply OCI patch and add comprehensive tests
themoriarti 2edf2ec
Remove PR_DESCRIPTION.md
themoriarti 4f495ad
Include stdio for OCI tests
themoriarti 208594d
Silence skip message in OCI tests
themoriarti 5e8658f
Apply formatting after fmt-fix
themoriarti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| # BFC OCI Image Specs Support | ||
|
|
||
| This document describes the OCI (Open Container Initiative) Image Specs support added to BFC (Binary File Container). | ||
|
|
||
| ## Overview | ||
|
|
||
| BFC now supports storing and managing OCI container images in its efficient single-file format. This allows BFC to be used as a storage backend for OCI-compliant container registries and image management systems. | ||
|
|
||
| ## Features | ||
|
|
||
| - **OCI Manifest Support**: Store and manage OCI image manifests | ||
| - **OCI Config Support**: Store and manage OCI image configurations | ||
| - **OCI Layer Support**: Store and manage OCI image layers | ||
| - **OCI Index Support**: Store and manage OCI image indexes | ||
| - **Validation**: Validate OCI manifests and configs | ||
| - **Extraction**: Extract BFC containers to OCI format | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### OCI Manifest Functions | ||
|
|
||
| ```c | ||
| // Create BFC container from OCI image manifest | ||
| int bfc_create_from_oci_manifest(bfc_t* bfc, const bfc_oci_manifest_t* manifest, const char* config_json); | ||
|
|
||
| // Get OCI manifest from BFC container | ||
| int bfc_get_oci_manifest(bfc_t* bfc, bfc_oci_manifest_t* manifest); | ||
|
|
||
| // Validate OCI manifest | ||
| int bfc_validate_oci_manifest(const bfc_oci_manifest_t* manifest); | ||
| ``` | ||
|
|
||
| ### OCI Layer Functions | ||
|
|
||
| ```c | ||
| // Add OCI layer to BFC container | ||
| int bfc_add_oci_layer(bfc_t* bfc, const bfc_oci_layer_t* layer, FILE* layer_data); | ||
|
|
||
| // List OCI layers in BFC container | ||
| int bfc_list_oci_layers(bfc_t* bfc, bfc_oci_layer_t** layers, size_t* layer_count); | ||
| ``` | ||
|
|
||
| ### OCI Index Functions | ||
|
|
||
| ```c | ||
| // Create BFC container from OCI image index | ||
| int bfc_create_from_oci_index(bfc_t* bfc, const bfc_oci_index_t* index); | ||
| ``` | ||
|
|
||
| ### Utility Functions | ||
|
|
||
| ```c | ||
| // Extract BFC container to OCI format | ||
| int bfc_extract_to_oci(bfc_t* bfc, const char* output_dir); | ||
|
|
||
| // Free OCI structures | ||
| void bfc_free_oci_manifest(bfc_oci_manifest_t* manifest); | ||
| void bfc_free_oci_config(bfc_oci_config_t* config); | ||
| void bfc_free_oci_layer(bfc_oci_layer_t* layer); | ||
| void bfc_free_oci_index(bfc_oci_index_t* index); | ||
| void bfc_free_oci_layers(bfc_oci_layer_t** layers, size_t layer_count); | ||
| ``` | ||
|
|
||
| ## Data Structures | ||
|
|
||
| ### OCI Manifest | ||
|
|
||
| ```c | ||
| typedef struct { | ||
| char* schema_version; // OCI schema version (e.g., "2.0.1") | ||
| char* media_type; // Media type (e.g., "application/vnd.oci.image.manifest.v1+json") | ||
| char* config_digest; // SHA256 digest of config | ||
| size_t config_size; // Size of config in bytes | ||
| char** layer_digests; // Array of layer digests | ||
| size_t layer_count; // Number of layers | ||
| char* annotations; // JSON annotations | ||
| } bfc_oci_manifest_t; | ||
| ``` | ||
|
|
||
| ### OCI Config | ||
|
|
||
| ```c | ||
| typedef struct { | ||
| char* architecture; // Target architecture (e.g., "amd64") | ||
| char* os; // Target OS (e.g., "linux") | ||
| char* created; // Creation timestamp | ||
| char* author; // Image author | ||
| char* config; // Container configuration | ||
| char* rootfs; // Root filesystem configuration | ||
| char* history; // Image history | ||
| } bfc_oci_config_t; | ||
| ``` | ||
|
|
||
| ### OCI Layer | ||
|
|
||
| ```c | ||
| typedef struct { | ||
| char* digest; // Layer digest (e.g., "sha256:abc123...") | ||
| char* media_type; // Layer media type | ||
| size_t size; // Layer size in bytes | ||
| char** urls; // Optional URLs for layer | ||
| size_t url_count; // Number of URLs | ||
| char* annotations; // Layer annotations | ||
| } bfc_oci_layer_t; | ||
| ``` | ||
|
|
||
| ## Usage Example | ||
|
|
||
| ```c | ||
| #include "bfc_oci.h" | ||
|
|
||
| int main() { | ||
| // Create BFC container | ||
| bfc_t* bfc = NULL; | ||
| bfc_create("image.bfc", 4096, 0, &bfc); | ||
|
|
||
| // Create OCI manifest | ||
| bfc_oci_manifest_t* manifest = calloc(1, sizeof(bfc_oci_manifest_t)); | ||
| manifest->schema_version = strdup("2.0.1"); | ||
| manifest->media_type = strdup("application/vnd.oci.image.manifest.v1+json"); | ||
| manifest->config_digest = strdup("sha256:abc123..."); | ||
| manifest->config_size = 1024; | ||
| manifest->layer_count = 1; | ||
| manifest->layer_digests = calloc(1, sizeof(char*)); | ||
| manifest->layer_digests[0] = strdup("sha256:def456..."); | ||
|
|
||
| // Add manifest to BFC | ||
| bfc_create_from_oci_manifest(bfc, manifest, "{\"architecture\":\"amd64\"}"); | ||
|
|
||
| // Add layer | ||
| bfc_oci_layer_t* layer = calloc(1, sizeof(bfc_oci_layer_t)); | ||
| layer->digest = strdup("sha256:def456..."); | ||
| layer->media_type = strdup("application/vnd.oci.image.layer.v1.tar+gzip"); | ||
| layer->size = 1024 * 1024; | ||
|
|
||
| FILE* layer_data = fopen("layer.tar.gz", "rb"); | ||
| bfc_add_oci_layer(bfc, layer, layer_data); | ||
| fclose(layer_data); | ||
|
|
||
| // Finish container | ||
| bfc_finish(bfc); | ||
| bfc_close(bfc); | ||
|
|
||
| // Cleanup | ||
| bfc_free_oci_manifest(manifest); | ||
| bfc_free_oci_layer(layer); | ||
|
|
||
| return 0; | ||
| } | ||
| ``` | ||
|
|
||
| ## Building with OCI Support | ||
|
|
||
| To build BFC with OCI support, include the OCI source file: | ||
|
|
||
| ```bash | ||
| gcc -o bfc_oci_example examples/oci_example.c src/bfc_oci.c src/bfc.c -Iinclude | ||
| ``` | ||
|
|
||
| ## Integration with Container Runtimes | ||
|
|
||
| BFC with OCI support can be integrated with: | ||
|
|
||
| - **Docker**: Use BFC as a storage backend for Docker images | ||
| - **Podman**: Use BFC as a storage backend for Podman images | ||
| - **containerd**: Use BFC as a storage backend for containerd | ||
| - **CRI-O**: Use BFC as a storage backend for CRI-O | ||
| - **Custom Runtimes**: Use BFC as a storage backend for custom container runtimes | ||
|
|
||
| ## Benefits | ||
|
|
||
| 1. **Efficiency**: Single file storage for entire OCI images | ||
| 2. **Compression**: Built-in zstd compression support | ||
| 3. **Encryption**: Built-in ChaCha20-Poly1305 encryption support | ||
| 4. **Integrity**: Built-in CRC32c checksums | ||
| 5. **Portability**: Easy to copy and transfer OCI images | ||
| 6. **ZFS Integration**: Works well with ZFS snapshots and clones | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| - **Registry Integration**: Direct integration with OCI registries | ||
| - **Layer Deduplication**: Automatic deduplication of identical layers | ||
| - **Compression Optimization**: Automatic compression level selection | ||
| - **Encryption Key Management**: Advanced encryption key management | ||
| - **Metadata Indexing**: Fast metadata search and indexing | ||
|
|
||
| ## Contributing | ||
|
|
||
| Contributions to OCI support are welcome! Please see the main BFC repository for contribution guidelines. | ||
|
|
||
| ## License | ||
|
|
||
| This OCI support code is licensed under the Apache License 2.0, same as the main BFC project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.