Skip to content

Commit

Permalink
feat(monocore): implement initial mc pull functionality (#132)
Browse files Browse the repository at this point in the history
* feat(monocore): implement initial image pull functionality

- Add pull_image command to monocore CLI
- Implement DockerRegistry pull_image functionality
- Add stub for SandboxesRegistry pull_image
- Add monoimage module for Sandboxes Registry integration
- Update OCI reference parsing to handle digests
- Add database migrations for image and layer tracking
- Remove Lock subcommand from MonocoreSubcommand enum

* feat(moncore): implement Docker image layer extraction

- Add layer extraction functionality to save downloaded layers
- Update database schema for layer chains and configs
- Add existence checks for images and layers to prevent re-downloads
- Improve logging with more detailed information
- Remove full_json storage from configs table
- Rename layer_stacks to layer_chains for better semantics
- Make Reference struct fields settable for registry fallback

* feat(core): implement OCI layer handling and filesystem metadata management

This commit adds support for handling OCI container image layers and improves filesystem metadata management across the codebase. Key changes include:

- Add rootfs.rs module for OCI layer handling with support for:
  - Creating monofs filesystems from OCI layers
  - Merging multiple layers following OCI layer semantics
  - Handling whiteouts and opaque directories
  - Preserving Unix metadata (mode, uid, gid, timestamps)

- Refactor filesystem metadata handling:
  - Move Unix metadata constants to shared location
  - Remove redundant symlink depth tracking
  - Improve permission handling during filesystem operations
  - Filesystem metadata structure has changed with the removal of symlink_depth field

- Update dependencies:
  - Upgrade rand to 0.9.0
  - Add async-recursion workspace dependency
  - Add monofs dependency to monocore

* feat(image): implement monofs layer creation and merging for Docker images

This commit adds functionality to create and merge monofs layers from pulled Docker
container images. Key changes include:

- Add new DB functions for saving/updating image and layer CIDs
- Implement monofs layer creation from extracted OCI layers
- Add layer merging to create final rootfs from ordered layers
- Update image pulling to store CIDs and verify layer completeness
- Add helper functions for layer CID management and verification
- Add tests for Docker image pulling and nginx file verification
- Add CID error handling to MonocoreError enum

The changes enable proper storage and tracking of monofs layers in the database,
with verification of layer completeness and proper merging order.
  • Loading branch information
appcypher authored Feb 11, 2025
1 parent 04abab4 commit b6dbe17
Show file tree
Hide file tree
Showing 35 changed files with 2,078 additions and 202 deletions.
130 changes: 107 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ tracing-subscriber = "0.3"
clap = { version = "4.5", features = ["color", "derive"] }
getset = "0.1"
procspawn = "1.0"
rand = "0.8"
rand = "0.9"
reqwest = { version = "0.12", features = ["stream", "json"] }
reqwest-middleware = "0.3" # Cannot upgrade to 0.4 due to https://github.com/TrueLayer/reqwest-middleware/issues/204
reqwest-retry = "0.6" # Cannot upgrade to 0.7 due to https://github.com/TrueLayer/reqwest-middleware/issues/204
monoutils-store = { version = "0.2", path = "./monoutils-store" }
monoutils = { version = "0.2", path = "./monoutils" }
monofs = { version = "0.2", path = "./monofs" }
multihash = "0.19"
multihash-codetable = "0.1"
chrono = { version = "0.4", features = ["serde"] }
Expand All @@ -65,3 +66,4 @@ pretty-error-debug = "0.3"
serde_ipld_dagcbor = "0.6"
sqlx = { version = "0.8", features = ["sqlite", "runtime-tokio-rustls"] }
regex = "1.10"
async-recursion = "1.1"
3 changes: 3 additions & 0 deletions monocore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ ipnetwork = { version = "0.21.0", features = ["serde"] }
sqlx.workspace = true
monoutils.workspace = true
regex.workspace = true
monoutils-store.workspace = true
monofs.workspace = true
async-recursion.workspace = true

[dev-dependencies]
test-log.workspace = true
Expand Down
13 changes: 12 additions & 1 deletion monocore/bin/monocore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ use monocore::{

#[tokio::main]
async fn main() -> MonocoreResult<()> {
tracing_subscriber::fmt::init();

// Parse command line arguments
let args = MonocoreArgs::parse();
match args.subcommand {
Some(MonocoreSubcommand::Init { path }) => {
tracing::info!("Initializing monocore project...");
tracing::info!("Initializing monocore project: path={path:?}");
management::init_menv(path).await?;
tracing::info!("Successfully initialized monocore project");
}
Some(MonocoreSubcommand::Pull {
image,
image_group,
name,
}) => {
tracing::info!("Pulling image: name={name}, image={image}, image_group={image_group}");
management::pull_image(name, image, image_group).await?;
tracing::info!("Successfully pulled image");
}
Some(_) => (), // TODO: implement other subcommands
None => {
MonocoreArgs::command().print_help()?;
Expand Down
Loading

0 comments on commit b6dbe17

Please sign in to comment.