ocibuild_tar (ocibuild v0.10.4)
View SourceIn-memory TAR archive builder.
This module builds POSIX ustar format TAR archives entirely in memory, without writing to disk. This is essential for building OCI layers efficiently.
The TAR format consists of 512-byte blocks:
- Each file has a 512-byte header followed by content padded to 512 bytes
- Archive ends with two 512-byte blocks of zeros
Summary
Functions
Create a TAR archive in memory.
Files are specified as {Path, Content, Mode} tuples.
Directories are created automatically for paths containing /.
TarData = ocibuild_tar:create([
{~"/app/myapp", AppBinary, 8#755},
{~"/app/config.json", ConfigJson, 8#644}
]).
-spec create(Files, Opts) -> binary() when Files :: [{Path :: binary(), Content :: binary(), Mode :: integer()}], Opts :: #{mtime => non_neg_integer()}.
Create a TAR archive in memory with options.
Options:
mtime: Unix timestamp for file modification times (for reproducible builds)
Files are sorted alphabetically for reproducibility.
%% With fixed mtime for reproducible builds
TarData = ocibuild_tar:create(Files, #{mtime => 1700000000}).