MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / create_build_context_tar

Function create_build_context_tar

crates/openshell-bootstrap/src/build.rs:269–281  ·  view source on GitHub ↗

Create a tar archive of a directory for use as a Docker build context. Walks `context_dir` recursively, respects a `.dockerignore` file if present, and adds matching files with paths relative to the context root.

(context_dir: &Path)

Source from the content-addressed store, hash-verified

267/// Walks `context_dir` recursively, respects a `.dockerignore` file if present,
268/// and adds matching files with paths relative to the context root.
269fn create_build_context_tar(context_dir: &Path) -> Result<Vec<u8>> {
270 let ignore_patterns = load_dockerignore(context_dir);
271
272 let mut builder = tar::Builder::new(Vec::new());
273
274 // Walk the directory tree and add entries, skipping ignored paths.
275 walk_and_add(context_dir, context_dir, &ignore_patterns, &mut builder)?;
276
277 builder
278 .into_inner()
279 .into_diagnostic()
280 .wrap_err("failed to finalize build context tar")
281}
282
283/// Recursively walk a directory and add entries to a tar archive,
284/// skipping paths that match `.dockerignore` patterns.

Callers 5

build_imageFunction · 0.85

Calls 2

load_dockerignoreFunction · 0.85
walk_and_addFunction · 0.85