Skip to content

Commit 9e63ee3

Browse files
committed
WIP - initial version for export to OCI layout documentation
Signed-off-by: Juan Bustamante <[email protected]>
1 parent d5c2de2 commit 9e63ee3

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
+++
2+
title="Export to OCI layout format"
3+
weight=3
4+
summary="Learn how to export your application image to disk in OCI layout format"
5+
+++
6+
7+
<div class="quote mb-4">
8+
The OCI Image Layout is the directory structure for OCI content-addressable blobs and location-addressable references.
9+
<div class="author">See the <a href="https://github.com/opencontainers/image-spec/blob/main/image-layout.md">specification</a></div>
10+
</div>
11+
12+
Exporting to OCI layout format is an **experimental** feature available on pack since version X.Y.Z
13+
14+
### 1. Enable experimental feature
15+
16+
Verify your pack version is equal or greater than X.Y.Z
17+
18+
```bash
19+
pack version
20+
```
21+
22+
Enable the experimental features on pack
23+
24+
```bash
25+
pack config experimental true
26+
```
27+
28+
You can confirm everything is fine, checking the `config.toml` file in your `PACK_HOME` installation folder, for example:
29+
30+
```bash
31+
cat ~/.pack/config.toml
32+
experimental = true
33+
layout-repo-dir = "<$HOME>/.pack/layout-repo"
34+
```
35+
36+
The configuration shows the experimental mode was **enabled** and a local directory to save images on disk was configured to path `<$HOME>/.pack/layout-repo`.
37+
38+
### 2. Build the app
39+
40+
If you haven't already, please follow the steps to [build an app](/docs/app-developer-guide/build-an-app).
41+
42+
The OCI layout feature must be enabled using the convention `oci:<path/to/save/image>` in the `<image-name>` parameter when invoking `pack build`.
43+
44+
For example:
45+
46+
```bash
47+
pack build oci:sample-app --path samples/apps/java-maven --builder cnbs/sample-builder:bionic
48+
```
49+
50+
It will save the image in a folder *sample-app* created in the current directory.
51+
52+
### 3. Check your image
53+
54+
**Congratulations!**
55+
56+
You can verify your application image was saved on disk in a folder called *sample-app* in your current directory in OCI layout format, for example:
57+
58+
```bash
59+
tree sample-app
60+
61+
sample-app
62+
├── blobs
63+
│ └── sha256
64+
│ ├── 2fa192256ce255c6ea6c1296eadfe2feba8094f40e6aa85e699645caca2e85d8
65+
│ ├── 5a44e4f7b58d74fe6f92dd7028075c91191128d1e2e7f39846fe061a9a98836e
66+
│ └── 622426666a7b61c086c84203082d5f64495be1f8b085137e53b0554cfcdb50ab
67+
├── index.json
68+
└── oci-layout
69+
```
70+
71+
---
72+
73+
## Extra configuration
74+
75+
### Skip saving your run-image layers on disk
76+
77+
If you don't need your `run-image` layers on disk, you can skip them using `--sparse` flag in your `pack build` command invocation
78+
79+
## Implementation notes
80+
81+
### Media Types
82+
83+
According to the OCI specification, the [compatibles media types](https://github.com/opencontainers/image-spec/blob/main/media-types.md#compatibility-matrix) for the index.json files must be:
84+
85+
- `application/vnd.oci.image.index.v1+json` or
86+
- `application/vnd.docker.distribution.manifest.list.v2+json`
87+
88+
If you are trying to use the lifecycle directly without using `pack` to export your image, take on consideration that tools like:
89+
90+
[skopeo](https://github.com/containers/skopeo)
91+
```bash
92+
skopeo copy -a docker://<your-image> <dest>
93+
```
94+
It will give you `application/vnd.oci.image.index.v1+json` media type, which is currently working
95+
96+
But [crane](https://github.com/google/go-containerregistry/tree/main/cmd/crane)
97+
98+
```bash
99+
crane pull <your-image> <dest> --format=oci
100+
```
101+
It will give you `application/vnd.docker.distribution.manifest.list.v2+json`, which will fail
102+
103+
104+
105+
106+

0 commit comments

Comments
 (0)