graph LR;
G[GOSH builder] --> A[parse dockerfile AST] --> D;
gosh build -> docker builder -> (dockerfile) #syntax=gosh-image-builder -> json(OCI) -> HASH dev: null -> sbom prod: sbom -> new.sbom == old.sbom
sbom.spdx.json -> works as a lock file
graph LR;
GOSH[GOSH Anytree builder] --> SBOM[`sbom.spdx.json`];
Dockerfile[Dockerfile AST] --> GOSH;
cargo[cargo.toml] --> GOSH;
- parse Dockerfile AST (see below)
- add sbom images
- prepare and parse Cargo.lock (for now: it's on developer)
- add sbom cargo deps
?? this format is under research
----------------------------------
sbom.spdx.json | cache (db)
----------------------------------
- root | hash
- 1st lvl dep | hash
- 2nd lvl dep
- 1st lvl dep
- 1st lvl dep
graph LR;
sbom --> gosh;
gosh[gosh builder] --llb + mount--> docker --> OCI[OCI image];
gosh build --collapsed-sbom {gosh-url}
# dockerfile -> sbom -> leaf from gosh(check sbom exists)
# - dockerfile -> sbom
-
clone repo from gosh
$ ls -la - Gosh.yaml - Dockerfile - sbom.spdx.json
-
Using
sbom.spdx.json
+gosh.yaml
start builddockerfile: path: Dockerfile tag: gosh-builder-result prepare: - cargo
-
parse dockerfile (use Go implementation from Moby)
-
get arbitrary representation of AST
-
for each image:
- build image recursivly + localy remember @sha:923847298374 of image
-
AST llb replace image name -> image_name@sha:3940823 from 3.2.1
-
compare stable hash for each image with sbom stable image hash
for each image: stable_image_hash(image) in sbom
-
?(TODO: research): in the end: json representation llb for docker builder
-
-
(if cargo) prepare dependencies from sbom (as if it's lock file) prepare-dependencies-from-sbom
-
docker build (network none)
- mount dependencies
- normal docker build phase (low-level builder aka llb)
gosh build reads sbom.json
- downloads all dependencies
- cargo dependency
- (not implemented yet -- will be plugins)
if cargo: - creates(or reservers) all mounts /root/.cargo/registy ... needs research
// 1. Assumption // /($path/dir inside repo) // - sbom.spdx.json // - Dockerfile // - with: RUN --mount=type=bind,source=./.gosh/cargo/registry,target=/root/.cargo/registry // - Gosh.yaml // // 2. SBOM made correctly // // // gosh anytree build (-q) gosh://<repo_url>#:<path/dir> // - prepare $run_dir (aka ~/.cache/gosh/builder/run_dir_random_UUID) // - git clone $run_dir/repo_root // - git checkout $tree_hash // - $CWD = $run_dir/path/dir // - read Gosh.yaml // - if cargo plugin // - call_cargo_plugin($CWD) // - cargo -> registry // - target_image_sha := call_go_gosh_builder($CWD) rec call gosh_anytree_build_ // return stdout -> target_image_sha