Skip to content

Add SIP for distributing Spin applications using OCI registries #1033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 19, 2023

Conversation

radu-matei
Copy link
Member

This extracts just the improvement proposal from #1014, so we can start iterating on the implementation separately.

Signed-off-by: Radu Matei [email protected]

Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one minor suggestion related to the separation of this PR

Copy link
Contributor

@kate-goldenring kate-goldenring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Should also add the reference to this SIP from index.md: https://github.com/fermyon/spin/blob/main/docs/content/sips/index.md.

@radu-matei
Copy link
Member Author

Added a link to the prototype in #1014 and updated the SIP index.

@radu-matei radu-matei merged commit 5172f03 into spinframework:main Jan 19, 2023
@radu-matei radu-matei deleted the oci-sip branch January 19, 2023 08:13
Copy link
Collaborator

@michelleN michelleN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

radu-matei added a commit to radu-matei/spin that referenced this pull request Jan 31, 2023
This commit adds experimental support for distributing Spin applications
using OCI registries.

Specifically, it uses the OCI Artifacts specification
(https://github.com/opencontainers/artifacts) to package and distribute Spin
applications.

This PR implements `spin oci push`, `spin oci pull`, and `spin oci run`
to interact with a supporting container registry - for example:

```bash
$ spin oci push ghcr.io/<username>/my-spin-application:v1
INFO spin_publish::oci::client: Pushed "https://ghcr.io/v2/<username>/my-spin-application/manifests/sha256:9f4e7eebb27c0174fe6654ef5e0f908f1edc8f625324a9f49967ccde44a6516b"
$ spin oci pull ghcr.io/<username>/my-spin-application:v1
INFO spin_publish::oci::client: Pulled ghcr.io/<username>/my-spin-application:v1@sha256:9f4e7eebb27c0174fe6654ef5e0f908f1edc8f625324a9f49967ccde44a6516b
$ spin oci run ghcr.io/<username>/my-spin-application:v1
INFO spin_publish::oci::client: Pulled ghcr.io/<username>/my-spin-application:v1@sha256:9f4e7eebb27c0174fe6654ef5e0f908f1edc8f625324a9f49967ccde44a6516b
```

Following the SIP (spinframework#1033), this PR
defines a new `config.mediaType` for a Spin application,
`application/vnd.fermyon.spin.application.v1+config`, and two media
types for the potential content that can be found in such an artifact:
`application/vnd.wasm.content.layer.v1+wasm` for a Wasm module, and
`application/vnd.wasm.content.layer.v1+data` for a static file.
(Note that the media types *can* change in a future iteration of this
experimental work if a community consensus on the media type used to
represent Wasm is reached.)
Following the SIP, this PR distributes the Spin lockfile for a given
application as the OCI configuration object.

This PR also introduces a global cache for layers and
manifests pulled from the registry. This is a content addressable cache,
and its use will be extended in the future for Wasm modules pulled from
HTTP sources.

Currently, `spin oci pull` (or `spin oci run`) will always make at least
an initial request to the registry to fetch the manifest from the
registry. After the manifest is fetched, already pulled layers will not
be pulled again.
In a future commit, the behavior of the initial manifest fetch
regardless of its existence in the cache will be controllable by a flag.

Signed-off-by: Radu Matei <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants