Skip to content

Commit

Permalink
improving readme
Browse files Browse the repository at this point in the history
  • Loading branch information
agracey committed Jan 6, 2022
1 parent 0b0f55f commit 5ade0ef
Showing 1 changed file with 79 additions and 4 deletions.
83 changes: 79 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ With the MetaBuildpack, you can easily describe what assets and processes are ne
- [x] Caching
- [ ] Bill of materials (sbom)
- [x] Launch configuration
- [ ] Tracing of Pipeline (in progress)
- [-] Tracing of Pipeline (in progress)
- [x] Published builder image and stack with tool included (docker.io/atgracey/metabuildpackbase:latest)
- [ ] Automated stack builds
- - [ ] x86_64
Expand All @@ -26,8 +26,83 @@ With the MetaBuildpack, you can easily describe what assets and processes are ne

## How to use

Full story to be written when I can. See ./testing/runtest.sh for clues.
I'm building a stack that anyone can use:

```
[stack]
id = "opensuse.stack.leap15.3"
run-image = "registry.opensuse.org/home/atgracey/opensuse_leap_15.3/cnbp_run:latest"
build-image = "docker.io/atgracey/metabuildpackbuild:latest"
```
Note: I'll be moving the build image to registry.opensuse.org as soon as I get the rust code built there as well.

To use the program, run
`cargo run -- --phase build -f ./noop-spec.json -e /tmp/env/ -p /tmp/plan.json -l /tmp/`

You can use this inside your detect and build bash scripts with:

```
#!/usr/bin/env bash
set -euo pipefail
env_dir="$1/env"
plan_path="$2"
/usr/local/bin/metabuildpack --phase detect -b $CNB_BUILDPACK_DIR -f $CNB_BUILDPACK_DIR/spec.json -e $env_dir -p $plan_path
exit $?
```

and

```
#!/usr/bin/env bash
set -euo pipefail
layers_dir="$1"
env_dir="$2/env"
plan_path="$3"
/usr/local/bin/metabuildpack --phase build -b $CNB_BUILDPACK_DIR -f $CNB_BUILDPACK_DIR/spec.json -e $env_dir -p $plan_path -l $layers_dir
exit $?
```


With those scripts in place, the last part is to write a spec file.

I wrote this one to install node in an airgapped manner.

Note: I'm adding comments that will break copy and paste!

```
{
"name":"nodejs-bins", # name used to log and trace correctly
"layers":[{
"name":"nodebin", # layers can be used to cache files across builds, expose files to the published image, or expose files to later buildpacks
"cache": true,
"launch": true,
"build": true
}],
"environment":[{ # This allows us to set variables in a more dynamic way, if a value is passed in to the build process by the end user, it will superscede what's defined here.
"key": "PATH",
"default": "{{env.PATH}}:{{layers_dir}}/nodebin/node-v17.0.1-linux-x64/bin/"
}],
"detect": { # You can decide whether to run or not based on existence of files or the result of a script.
"exists": [{
"path": "./package.json"
}],
"scripts": []
},
"build":[{ # When building, you can pull files from other places, from a set of files provided in the buildpack itself, and run scripts.
"remote": [],
"local": [],
"scripts": [{
"command": "tar -xf {{buildpack_dir}}/assets/node.tar.xz -C {{layers_dir}}/nodebin/"
}]
}],
"process":"{{layers_dir}}/nodebin/node-v17.0.1-linux-x64/bin/node index.js" # You can also set the default command the published container will run
}
```



A reference set of buildpacks can be found at: https://github.com/agracey/buildpack_example

0 comments on commit 5ade0ef

Please sign in to comment.