Skip to content

Commit d694d96

Browse files
committed
README: Add a deploy example with raw image-spec layouts
For folks who want to diverge as little as possible from things already in image-spec. Downsides to this approach include: * Non-sharded blobs [1], although it's not clear to me that modern filesystems suffer from having many entries in one directory [2]. * Possible duplicate blobs between two layouts. You can address this with symlinks or similar, but you'd need extra tooling to do that. With a single CAS bucket, there's only one place that the blob could be, so deduping is free (but garbage collection becomes more complicated). [1]: opencontainers/image-spec#449 [2]: opencontainers/image-spec#94 (comment)
1 parent 513946b commit d694d96

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,41 @@ To publish additional images matching the `example.com/app#…` family of [host-
140140
To publish additional images matching new families (e.g. `example.com/other-app#…`), add their entries to new `/srv/example.com/oci-index/` indexes (e.g. `/srv/example.com/oci-index/other-app`).
141141
All the CAS blobs can go in the same bucket under `/srv/example.com/oci-cas`, although if you want you can adjust the `casEngines` entries and keep CAS blobs in different buckets.
142142

143+
## Example: Serving OCI layouts from Nginx
144+
145+
As an alternative to the [previous example](#example-serving-everything-from-one-nginx-server), you can bucket your CAS blobs by serving [OCI layouts][layout] directly.
146+
If your layout `index.json` are not setting `casEngines` and you are unwilling to update them to do so, you can [set `casEngines` in you ref-engines object](ref-engine-discovery.md#ref-engines-objects) at `/srv/example.com/.well-known/oci-ref-engines`:
147+
148+
```json
149+
{
150+
"refEngines": [
151+
{
152+
"protocol": "oci-index-template-v1",
153+
"uri": "https://{host}/oci-image/{path}/index.json"
154+
}
155+
],
156+
"casEngines": [
157+
{
158+
"protocol": "oci-cas-template-v1",
159+
"uri": "https://example.com/oci-image/{path}/blobs/{algorithm}/{encoded}"
160+
}
161+
]
162+
}
163+
```
164+
165+
Then copy your [layout directories][layout] under `/srv/example.com/oci-image/{path}` to deploy them.
166+
167+
The Nginx config from the [previous example](#example-serving-everything-from-one-nginx-server) would need an adjusted [`location`][location] for the index media type:
168+
169+
```
170+
location ~ ^/oci-image/.*/index.json$ {
171+
types {}
172+
default_type application/vnd.oci.image.index.v1+json;
173+
}
174+
```
175+
143176
[image-spec]: https://github.com/opencontainers/image-spec
144177
[image-spec-canonical-json]: https://github.com/opencontainers/image-spec/blob/v1.0.0/considerations.md#json
178+
[layout]: https://github.com/opencontainers/image-spec/blob/v1.0.0/image-layout.md
179+
[location]: http://nginx.org/en/docs/http/ngx_http_core_module.html#location
145180
[Nginx]: https://nginx.org/

0 commit comments

Comments
 (0)