Skip to content

Commit 2916956

Browse files
first draft of builder spec
Signed-off-by: Joe Kimmel <jkimmel@vmware.com>
1 parent 83ce49f commit 2916956

File tree

1 file changed

+198
-14
lines changed

1 file changed

+198
-14
lines changed

distribution.md

Lines changed: 198 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ This document specifies the artifact format, delivery mechanism, and order resol
1515

1616
## Distribution API Version
1717

18-
This document specifies Distribution API version `0.3`.
18+
This document specifies Distribution API version `0.4`.
1919

2020
Distribution API versions:
2121
- MUST be in form `<major>.<minor>` or `<major>`, where `<major>` is equivalent to `<major>.0`
2222
- When `<major>` is greater than `0` increments to `<minor>` SHALL exclusively indicate additive changes
23+
- Each Distributable artifact MUST contain the label io.buildpacks.distribution.api denoting the distribution API
2324

2425
## Artifact Format
2526

@@ -43,29 +44,212 @@ Each buildpack layer blob MUST contain a single buildpack at the following file
4344
/cnb/buildpacks/<buildpack ID>/<buildpack version>/
4445
```
4546

47+
If the buildpack ID contains a `/`, it MUST be replaced with `_` in the directory name.
48+
49+
A buildpack MUST contain a `buildpack.toml` file at its root directory.
50+
51+
4652
A buildpack ID, buildpack version, and at least one stack MUST be provided in the OCI image config as a Label.
4753

48-
Label: `io.buildpacks.buildpackage.metadata`
54+
#### Labels
55+
56+
The following labels MUST be set in the buildpack image(through the image config's `Labels` field):
57+
58+
| Label | Description |
59+
| ------------------------------------ | ------------------------------------------------------------------------------------------------- |
60+
| `io.buildpacks.buildpack.metadata` | A JSON object representing information about the packaged entrypoint buildpack |
61+
| `io.buildpacks.buildpack.layers` | A JSON object representing information about all packaged buildpacks and their associated layers. |
62+
63+
##### `io.buildpacks.buildpack.metadata` (JSON)
64+
4965
```json
5066
{
51-
"id": "<entrypoint buildpack ID>",
52-
"version": "<entrypoint buildpack version>",
53-
"stacks": [
54-
{
55-
"id": "<stack ID>",
56-
"mixins": ["<mixin name>"]
67+
"id": "<buildpack ID (required)>",
68+
"name": "<buildpack name (optional)>",
69+
"version": "<buildpack version (required)>",
70+
"homepage": "<buildpack home page (optional)>",
71+
}
72+
```
73+
74+
##### `io.buildpacks.buildpack.layers` (JSON)
75+
76+
```json
77+
{
78+
# schema of a meta-buildpack
79+
"<buildpack ID (required)>": {
80+
"<buildpack version (required)>": {
81+
"api": "<buildpack API (required)>",
82+
"order": [
83+
{
84+
"group": [
85+
{
86+
"id": "<inner buildpack ID (required)>",
87+
"version": "<inner buildpack version (required)>"
88+
}
89+
]
90+
}
91+
],
92+
"layerDiffID": "<diff ID of buildpack layer (required)>",
93+
"homepage": "<buildpack homepage (optional)>",
94+
"name": "<buildpack name (optional)>"
95+
}
96+
},
97+
# schema of a regular buildpack
98+
"<buildpack ID (required)>": {
99+
"<buildpack version (required)>": {
100+
"api": "<buildpack API (required)>",
101+
"layerDiffID": "<diff ID of buildpack layer (required)>",
102+
"homepage": "<buildpack homepage (optional)>",
103+
"name": "<buildpack name (optional)>"
57104
}
58-
]
105+
}
59106
}
60107
```
61108

109+
For each buildpack layer, the buildpack ID and the buildpack version MUST be provided in `io.buildpacks.buildpack.layers`.
110+
62111
The buildpack ID and version MUST match a buildpack provided by a layer blob.
63112

64-
For a buildpackage to be valid, each `buildpack.toml` describing a buildpack implementation MUST have all listed stacks.
113+
For a buildpackage to be valid, each `buildpack.toml` describing a buildpack implementation MUST have all listed targets.
114+
115+
### Builder
116+
117+
The following specifies the artifact format for a buildpacks builder.
118+
119+
A builder is an OCI Image that provides a distributable build environment.
120+
121+
A platform supporting builders SHOULD allow users to configure the build environment for a provided builder.
122+
123+
#### General Requirements
124+
125+
The builder image MUST contain an implementation of the [lifecycle](#lifecycle), and a [build-time](#build-image) environment, and MAY contain [buildpacks](#buildpackage). Platforms SHOULD use builders to ease the build process.
126+
127+
#### Filesystem
128+
129+
A builder MUST have the following directories/files:
130+
131+
* `/cnb/order.toml` &rarr; As defined in the [platform specification](https://github.com/buildpacks/spec/blob/main/platform.md#ordertoml-toml).
132+
133+
#### Environment Variables
134+
135+
A builder MUST be an extension of a Build Image, and MUST retain all the specified environment variables set on the original build image, as specified in the Build Image specifications.
136+
137+
#### Labels
65138

66-
For each listed stack, all associated buildpacks MUST be a candidate for detection when the entrypoint buildpack ID and version are selected.
139+
A builder MUST be an extension of a Build Image, and MUST retain all the specified Labels set on the original build image, as specified in the Build Image specifications.
140+
141+
A builder image MUST contain an implementation of the [lifecycle](#lifecycle), and MUST retain all the specified Labels set on the original Lifecycle image, as specified in the lifecycle distribution specifications.
142+
143+
A builder image MAY contain buildpacks, and MAY retain all the specified Labels set on the original buildpackage, as specified in the [buildpackage](#buildpackage) specification with the following exceptions:
144+
145+
- `io.buildpacks.buildpack.metadata` MUST not be set.
146+
- `io.buildpacks.buildpack.layers` on the builder SHOULD be a merged version based on all buildpackages combined and thereby have of all packaged buildpacks represented.
147+
148+
In addition to all inherited labels above, the following labels MUST be set in the builder environment (through the image config's `Labels` field):
149+
150+
| Label | Description |
151+
| -------------------------------- | ------------------------------------------------------------- |
152+
| `io.buildpacks.builder.metadata` | A JSON object representing builder metadata. |
153+
| `io.buildpacks.buildpack.order` | A JSON object representation of the `/cnb/order.toml` file. |
154+
155+
##### `io.buildpacks.builder.metadata` (JSON)
156+
157+
```json
158+
{
159+
"description": "<string>",
160+
"createdBy": {
161+
"name": "<string>",
162+
"version": "<string>",
163+
}
164+
}
165+
```
166+
167+
Where:
168+
169+
- `description` (optional) is a human readable description of the builder.
170+
- `createdBy` (optional) is information about the tool that created the builder.
171+
- `name` (optional) is the name of the tool that created the builder.
172+
- `version` (optional) is the version of the tool that created the builder.
173+
174+
## Data Format
175+
176+
### Files
177+
178+
#### `builder.toml` (TOML)
179+
```toml
180+
description = "a human readable description output when you run `pack inspect-builder`"
181+
182+
[[buildpacks]]
183+
id = "<buildpack ID>"
184+
version = "<buildpack version>"
185+
uri = "<uri>"
186+
187+
[[order]]
188+
[[order.group]]
189+
id = "<buildpack ID>"
190+
version = "<buildpack version>"
191+
optional = false
192+
193+
[stack]
194+
id = "<stack id>"
195+
build-image = "build image"
196+
run-image = "run image"
197+
run-image-mirrors = "mirrors"
198+
199+
[build]
200+
image = "build image"
201+
202+
[run]
203+
[[run.images]]
204+
image = "run image"
205+
mirrors = "mirrors"
206+
207+
```
208+
209+
Where:
210+
- buildpacks list MAY be provided.
211+
- buildpacks.id and .version are optional but if provided MUST match an available buildpack in its buildpack.toml file.
212+
- buildpacks.uri MUST be provided.
213+
- order list MUST be provided and MUST have at least one group list
214+
- order.group.id
215+
- MUST be provided
216+
- SHOULD match an available buildpack in the buildpacks list
217+
- MUST be unique within a group
218+
- MAY be repeated within the order
219+
- order.group.version (optional) MAY be omitted if the ID alone is sufficient to identify a unique buildpack.
220+
- order.group.optional (optional) MUST be a boolean value specifying whether or not this buildpack is optional during detection.
221+
- stack MAY be provided to platforms >= 0.12, but is deprecated in favor of `build` and `run` (see below). MUST be provided to platforms <= 0.11.
222+
- build-image MUST be included in a stack
223+
- run-image MUST be included
224+
- run-image-mirrors MAY be included
225+
- build SHOULD be provided to platforms >= 0.12, and MUST include an image
226+
- run SHOULD be provided to platforms >= 0.12
227+
- run MUST have at least one `images` entry
228+
- each `run.images` MUST include an image
229+
- each `run.images` MAY include a list of mirrors (in the format `["mirror url", "mirror, url", ...]`)
230+
- either stack or build and run images MUST be provided.
231+
232+
233+
#### `package.toml` (TOML)
234+
235+
```(toml)
236+
[buildpack]
237+
uri = "uri"
238+
239+
[[buildpacks]]
240+
uri = "uri"
241+
242+
[platform]
243+
os = "operating system"
244+
245+
[[dependencies]]
246+
uri = "uri"
247+
image = "image uri"
248+
249+
```
67250

68-
Each stack ID MUST only be present once.
69-
For a given stack, the `mixins` list MUST enumerate mixins such that no included buildpacks are missing a mixin for the stack.
251+
Where:
252+
- buildpack or buildpacks MUST be present, and MUST include a URI, which MAY be a relative or absolute path, or URL.
253+
- platform MAY be provided to specify the operating system compatibility. If provided, `os` SHOULD be either `linux` (default) or `windows`
254+
- dependencies list MAY be provided to specify URIs of order groups within a meta-buildpack.
70255

71-
Fewer stack entries as well as additional mixins for a stack entry MAY be specified.

0 commit comments

Comments
 (0)