Skip to content

Commit f6e5164

Browse files
authored
Merge pull request #21588 from dvdksn/build-oci-artifact-opt
build: add oci-artifact exporter opt
2 parents ac388dc + d9c1469 commit f6e5164

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

content/manuals/build/exporters/image-registry.md

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following table describes the available parameters that you can pass to
3737
| `force-compression` | `true`,`false` | `false` | Forcefully apply compression, see [compression][1] |
3838
| `rewrite-timestamp` | `true`,`false` | `false` | Rewrite the file timestamps to the `SOURCE_DATE_EPOCH` value. See [build reproducibility][4] for how to specify the `SOURCE_DATE_EPOCH` value. |
3939
| `oci-mediatypes` | `true`,`false` | `false` | Use OCI media types in exporter manifests, see [OCI Media types][2] |
40+
| `oci-artifact` | `true`,`false` | `false` | Attestations are formatted as OCI artifacts, see [OCI Media types][2] |
4041
| `unpack` | `true`,`false` | `false` | Unpack image after creation (for use with containerd) |
4142
| `store` | `true`,`false` | `true` | Store the result images to the worker's (for example, containerd) image store, and ensures that the image has all blobs in the content store. Ignored if the worker doesn't have image store (when using OCI workers, for example). |
4243
| `annotation.<key>` | String | | Attach an annotation with the respective `key` and `value` to the built image,see [annotations][3] |
@@ -45,6 +46,7 @@ The following table describes the available parameters that you can pass to
4546
[2]: _index.md#oci-media-types
4647
[3]: #annotations
4748
[4]: https://github.com/moby/buildkit/blob/master/docs/build-repro.md
49+
[5]: /manuals/build/metadata/attestations/_index.md#attestations-as-oci-artifacts
4850

4951
## Annotations
5052

content/manuals/build/metadata/attestations/_index.md

+81
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ the attestations to an image manifest, since it's outputting a directory of
9595
files or a tarball, not an image. Instead, these exporters write the
9696
attestations to one or more JSON files in the root directory of the export.
9797

98+
## Example
99+
98100
The following example shows a truncated in-toto JSON representation of an SBOM
99101
attestation.
100102

@@ -161,6 +163,85 @@ attestation.
161163
To deep-dive into the specifics about how attestations are stored, see
162164
[Image Attestation Storage (BuildKit)](attestation-storage.md).
163165

166+
## Attestation manifest format
167+
168+
Attestations are stored as manifests, referenced by the image's index. Each
169+
_attestation manifest_ refers to a single _image manifest_ (one
170+
platform-variant of the image). Attestation manifests contain a single layer,
171+
the "value" of the attestation.
172+
173+
The following example shows the structure of an attestation manifest:
174+
175+
```json
176+
{
177+
"schemaVersion": 2,
178+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
179+
"config": {
180+
"mediaType": "application/vnd.oci.image.config.v1+json",
181+
"size": 167,
182+
"digest": "sha256:916d7437a36dd0e258e64d9c5a373ca5c9618eeb1555e79bd82066e593f9afae"
183+
},
184+
"layers": [
185+
{
186+
"mediaType": "application/vnd.in-toto+json",
187+
"size": 1833349,
188+
"digest": "sha256:3138024b98ed5aa8e3008285a458cd25a987202f2500ce1a9d07d8e1420f5491",
189+
"annotations": {
190+
"in-toto.io/predicate-type": "https://spdx.dev/Document"
191+
}
192+
}
193+
]
194+
}
195+
```
196+
197+
### Attestations as OCI artifacts
198+
199+
You can configure the format of the attestation manifest using the
200+
[`oci-artifact` option](/manuals/build/exporters/image-registry.md#synopsis)
201+
for the `image` and `registry` exporters. If set to `true`, the structure of
202+
the attestation manifest changes as follows:
203+
204+
- An `artifactType` field is added to the attestation manifest, with a value of `application/vnd.docker.attestation.manifest.v1+json`.
205+
- The `config` field is an [empty descriptor] instead of a "dummy" config.
206+
- A `subject` field is also added, pointing to the image manifest that the attestation refers to.
207+
208+
[empty descriptor]: https://github.com/opencontainers/image-spec/blob/main/manifest.md#guidance-for-an-empty-descriptor
209+
210+
The following example shows an attestation with the OCI artifact format:
211+
212+
```json
213+
{
214+
"schemaVersion": 2,
215+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
216+
"artifactType": "application/vnd.docker.attestation.manifest.v1+json",
217+
"config": {
218+
"mediaType": "application/vnd.oci.empty.v1+json",
219+
"size": 2,
220+
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
221+
"data": "e30="
222+
},
223+
"layers": [
224+
{
225+
"mediaType": "application/vnd.in-toto+json",
226+
"size": 2208,
227+
"digest": "sha256:6d2f2c714a6bee3cf9e4d3cb9a966b629efea2dd8556ed81f19bd597b3325286",
228+
"annotations": {
229+
"in-toto.io/predicate-type": "https://slsa.dev/provenance/v0.2"
230+
}
231+
}
232+
],
233+
"subject": {
234+
"mediaType": "application/vnd.oci.image.manifest.v1+json",
235+
"size": 1054,
236+
"digest": "sha256:bc2046336420a2852ecf915786c20f73c4c1b50d7803aae1fd30c971a7d1cead",
237+
"platform": {
238+
"architecture": "amd64",
239+
"os": "linux"
240+
}
241+
}
242+
}
243+
```
244+
164245
## What's next
165246

166247
Learn more about the available attestation types and how to use them:

0 commit comments

Comments
 (0)