Skip to content

Commit 1f6a3ad

Browse files
author
Natalie Arellano
authored
Merge pull request #326 from buildpacks/buildpack/0.9
Finalize buildpack/0.9
2 parents d8e7ab1 + de932c4 commit 1f6a3ad

File tree

9 files changed

+408
-153
lines changed

9 files changed

+408
-153
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ When the specification refers to a path in the context of an OCI layer tar (e.g.
5050

5151
These documents currently specify:
5252

53-
- Buildpack API: `0.8`
53+
- Buildpack API: `0.9`
5454
- Distribution API: `0.3`
5555
- Platform API: `0.10`

buildpack.md

Lines changed: 166 additions & 152 deletions
Large diffs are not rendered by default.

image_extension.md

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Image Extension Interface Specification (**experimental**)
2+
3+
This document specifies the interface between a lifecycle program and one or more image extensions.
4+
5+
## Table of Contents
6+
7+
<!-- Using https://github.com/yzhang-gh/vscode-markdown to manage toc -->
8+
- [Image Extension Interface Specification](#image-extension-interface-specification)
9+
- [Table of Contents](#table-of-contents)
10+
- [Image Extension API Version](#image-extension-api-version)
11+
- [Image Extension Interface](#image-extension-interface)
12+
- [Detection](#detection)
13+
- [Generation](#generation)
14+
- [Phase: Generation](#phase-generation)
15+
- [Purpose](#purpose)
16+
- [Process](#process)
17+
- [Dockerfile Requirements](#dockerfile-requirements)
18+
- [Data Format](#data-format)
19+
- [Files](#files)
20+
- [extension.toml (TOML)](#extensiontoml-toml)
21+
22+
## Image Extension API Version
23+
24+
This document accompanies Buildpack API version `0.9`.
25+
26+
## Image Extension Interface
27+
28+
Unless otherwise noted, image extensions are expected to conform to the [Buildpack Interface Specification](buildpack.md).
29+
30+
### Detection
31+
32+
Executable: `/bin/detect`, Working Dir: `<app[AR]>`
33+
34+
Image extensions participate in the buildpack [detection](buildpack.md#detection) process, with the same interface for `/bin/detect`. However:
35+
- Detection is optional for image extensions, and they are assumed to pass detection when `/bin/detect` is not present.
36+
- If an image extension is missing `/bin/detect`, the image extension root `/detect` directory MUST be treated as a pre-populated `<output>` directory.
37+
- Instead of the `CNB_BUILDPACK_DIR` input, image extensions MUST receive a `CNB_EXTENSION_DIR` which MUST be the absolute path of the extension root directory.
38+
- Image extensions MUST only output `provides` entries to the build plan. They MUST NOT output `requires`.
39+
40+
### Generation
41+
42+
Executable: `/bin/generate`, Working Dir: `<app[AR]>`
43+
44+
Image extensions participate in a generation process that is similar to the buildpack [build](buildpack.md#build) process, with an interface that is similar to `/bin/build`. However:
45+
- Image extensions' `/bin/generate` MUST NOT write to the app directory.
46+
- Instead of the `CNB_LAYERS_DIR` input, image extensions MUST receive a `CNB_OUTPUT_DIR` which MUST be the absolute path of an `<output>` directory and MUST NOT be the path of the buildpack layers directory.
47+
- Instead of the `CNB_BUILDPACK_DIR` input, image extensions MUST receive a `CNB_EXTENSION_DIR` which MUST be the absolute path of the extension root directory.
48+
- If an image extension is missing `/bin/generate`, the image extension root `/generate` directory MUST be treated as a pre-populated `<output>` directory.
49+
50+
## Phase: Generation
51+
52+
### Purpose
53+
54+
The purpose of the generation phase is to generate Dockerfiles that can be used to define the build and/or runtime base image. The generation phase MUST NOT be run for Windows builds.
55+
56+
### Process
57+
58+
**GIVEN:**
59+
- The final ordered group of image extensions determined during the detection phase,
60+
- A directory containing application source code,
61+
- The Buildpack Plan,
62+
- An `<output>` directory used to store generated artifacts,
63+
- A shell, if needed,
64+
65+
For each image extension in the group in order, the lifecycle MUST execute `/bin/generate`.
66+
67+
1. **If** the exit status of `/bin/generate` is non-zero, \
68+
**Then** the lifecycle MUST fail the build.
69+
70+
2. **If** the exit status of `/bin/generate` is zero,
71+
1. **If** there are additional image extensions in the group, \
72+
**Then** the lifecycle MUST proceed to the next image extension's `/bin/generate`.
73+
74+
2. **If** there are no additional image extensions in the group, \
75+
**Then** the lifecycle MUST proceed to the build phase.
76+
77+
For each `/bin/generate` executable in each image extension, the lifecycle:
78+
79+
- MUST provide path arguments to `/bin/generate` as described in the [generation](#generation) section.
80+
- MUST configure the build environment as described in the [Environment](buildpack.md#environment) section.
81+
- MUST provide all `<plan>` entries that were required by any buildpack in the group during the detection phase with names matching the names that the image extension provided.
82+
83+
Correspondingly, each `/bin/generate` executable:
84+
85+
- MAY read from the `<app>` directory.
86+
- MUST NOT write to the `<app>` directory.
87+
- MAY read the build environment as described in the [Environment](buildpack.md#environment) section.
88+
- MAY read the Buildpack Plan.
89+
- MAY log output from the build process to `stdout`.
90+
- MAY emit error, warning, or debug messages to `stderr`.
91+
- MAY write either or both of `build.Dockerfile` and `run.Dockerfile` to the `<output>` directory. This file MUST adhere to the requirements listed below.
92+
- MAY write key-value pairs to `<output>/extend-config.toml` that are provided as build args to build.Dockerfile when extending the build image.
93+
- MUST NOT write SBOM (Software-Bill-of-Materials) files as described in the [Software-Bill-of-Materials](#software-bill-of-materials) section.
94+
95+
#### Dockerfile Requirements
96+
97+
A `run.Dockerfile`
98+
99+
- MAY contain a single `FROM` instruction
100+
- MUST NOT contain any other instructions
101+
102+
A `build.Dockerfile`
103+
104+
- MUST begin with:
105+
```bash
106+
ARG base_image
107+
FROM ${base_image}
108+
```
109+
- MUST NOT contain any other `FROM` instructions
110+
- MAY contain `ADD`, `ARG`, `COPY`, `ENV`, `LABEL`, `RUN`, `SHELL`, `USER`, and `WORKDIR` instructions
111+
- SHOULD NOT contain any other instructions
112+
- SHOULD use the `build_id` build arg to invalidate the cache after a certain layer. When the `$build_id` build arg is referenced in a `RUN` instruction, all subsequent layers will be rebuilt on the next build (as the value will change); the `build_id` build arg SHOULD be defaulted to 0 if used (this ensures portability)
113+
- SHOULD NOT edit `<app>`, `<layers>`, or `<workspace>` directories (see the [Platform Interface Specification](platform.md)) as changes will not be persisted
114+
115+
## Phase: Extension
116+
117+
### Purpose
118+
119+
The purpose of the extension phase is to apply the Dockerfiles generated in the generation phase to the appropriate base image. The extension phase MUST NOT be run for Windows builds.
120+
121+
### Process
122+
123+
**GIVEN:**
124+
- The final ordered group of Dockerfiles generated during the generation phase,
125+
- A list of build args for each Dockerfile specified during the generation phase,
126+
127+
For each Dockerfile in the group in order, the lifecycle MUST apply the Dockerfile to the base image as follows:
128+
129+
- The lifecycle MUST provide each Dockerfile with:
130+
- A `base_image` build arg
131+
- For the first Dockerfile, the value MUST be the original base image.
132+
- When there are multiple Dockerfiles, the value MUST be the intermediate image generated from the application of the previous Dockerfile.
133+
- A `build_id` build arg
134+
- The value MUST be a UUID
135+
136+
## Data Format
137+
138+
### Files
139+
140+
### extension.toml (TOML)
141+
142+
This section describes the 'Extension descriptor'.
143+
144+
```toml
145+
api = "<buildpack API version>"
146+
147+
[extension]
148+
id = "<extension ID>"
149+
name = "<extension name>"
150+
version = "<extension version>"
151+
homepage = "<extension homepage>"
152+
description = "<extension description>"
153+
keywords = [ "<string>" ]
154+
155+
[[extension.licenses]]
156+
type = "<string>"
157+
uri = "<uri>"
158+
```
159+
160+
Image extension authors MUST choose a globally unique ID, for example: "io.buildpacks.apt".
161+
162+
The image extension `id`, `version`, `api`, and `licenses` entries MUST follow the requirements defined in the [Buildpack Interface Specification](buildpack.md).
163+
164+
### extend-config.toml (TOML)
165+
166+
```toml
167+
[[build.args]]
168+
name = "<build arg name>"
169+
value = "<build arg value>"
170+
```
171+
172+
The image extension MAY specify any number of args.
173+
174+
For each arg, the image extension:
175+
- MUST specify a `name` to be the name of a build argument that will be provided to any output build.Dockerfile when extending the build base image.
176+
- MUST specify a `value` to be the value of the build argument that is provided.
177+
178+
### Build Plan (TOML)
179+
180+
See the [Buildpack Interface Specification](buildpack.md).
181+
182+
### Buildpack Plan (TOML)
183+
184+
See the [Buildpack Interface Specification](buildpack.md). Image extensions MUST satisfy all entries in the Buildpack Plan.

img/genmatrix.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# A quick script to use tex.s2cms.ru to generate various matrix svgs.
4+
# (requests were previously inlined directly from buildpack.md, this allows the doc to be read if the remote side is down)
5+
6+
wget -O matrix1.svg http://tex.s2cms.ru/svg/%0AO%20%3D%0A%5Cbegin%7Bbmatrix%7D%0AA%2C%20%26%20B%20%5C%5C%0AC%2C%20%26%20D%0A%5Cend%7Bbmatrix%7D%0A
7+
wget -O matrix2.svg http://tex.s2cms.ru/svg/%0AP%20%3D%0A%5Cbegin%7Bbmatrix%7D%0AE%2C%20%26%20F%20%5C%5C%0AG%2C%20%26%20H%0A%5Cend%7Bbmatrix%7D%0A
8+
wget -O matrix3.svg http://tex.s2cms.ru/svg/%0A%5Cbegin%7Bbmatrix%7D%0AE%2C%20%26%20O%2C%20%26%20F%0A%5Cend%7Bbmatrix%7D%20%3D%20%0A%5Cbegin%7Bbmatrix%7D%0AE%2C%20%26%20A%2C%20%26%20B%2C%20%26%20F%20%5C%5C%0AE%2C%20%26%20C%2C%20%26%20D%2C%20%26%20F%20%5C%5C%0A%5Cend%7Bbmatrix%7D%0A
9+
wget -O matrix4.svg http://tex.s2cms.ru/svg/%0A%5Cbegin%7Bbmatrix%7D%0AO%2C%20%26%20P%0A%5Cend%7Bbmatrix%7D%20%3D%20%0A%5Cbegin%7Bbmatrix%7D%0AA%2C%20%26%20B%2C%20%26%20E%2C%20%26%20F%20%5C%5C%0AA%2C%20%26%20B%2C%20%26%20G%2C%20%26%20H%20%5C%5C%0AC%2C%20%26%20D%2C%20%26%20E%2C%20%26%20F%20%5C%5C%0AC%2C%20%26%20D%2C%20%26%20G%2C%20%26%20H%20%5C%5C%0A%5Cend%7Bbmatrix%7D%0A
10+
11+
# add background color.. (helps with github darkmode)
12+
sed -i -e's/<svg/<svg style="background-color:white"/' matrix1.svg
13+
sed -i -e's/<svg/<svg style="background-color:white"/' matrix2.svg
14+
sed -i -e's/<svg/<svg style="background-color:white"/' matrix3.svg
15+
sed -i -e's/<svg/<svg style="background-color:white"/' matrix4.svg

img/matrix1.svg

Lines changed: 1 addition & 0 deletions
Loading

img/matrix2.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)