Skip to content
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

add support for oci-layout build-context #1173

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

deitch
Copy link
Contributor

@deitch deitch commented Jun 19, 2022

Adds to buildx the oci-layout: build-context capabilities added to buildkit in buildkit 2827.

Recommended by @tonistiigi . Remains incomplete, some things I wasn't sure about. Will comment inline.

@deitch
Copy link
Contributor Author

deitch commented Jun 19, 2022

Pulling in the updated buildkit lib updated a whole bunch of other things. go mod worked its magic. It all worked and compiled, so I didn't complain.

build/build.go Outdated Show resolved Hide resolved
build/build.go Outdated Show resolved Hide resolved
build/build.go Outdated Show resolved Hide resolved
build/build.go Outdated Show resolved Hide resolved
build/build.go Outdated
target.OCIStores = map[string]content.Store{
k: store,
}
target.FrontendAttrs["context:"+k] = "oci-layout:" + k
Copy link
Member

Choose a reason for hiding this comment

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

The value in here nees to include digest that you are expecting in https://github.com/moby/buildkit/blob/master/frontend/dockerfile/builder/build.go#L892

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that is it. I went through our buildkit PR, and could not recall which part did this. That helps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Take a look, I think I got it right.

Source an image from a local [OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md):

```console
$ docker buildx build --build-context foo=oci-layout:///path/to/local/layout@sha256:abcd12345 .
Copy link
Member

Choose a reason for hiding this comment

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

I think we should allow this input without the digest as well in here. If no digest is set it can look up index.json inside this dir and see if it has one descriptor and then set it as the expected digest. If there is ambiguity then it can produce an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am hesitant about this, as it wades into a deep unresolved issue around what actually should be in index.json. I have seen those that only include tags, others that include entire image refs, making the layout directory essentially into a full registry. I have implemented. both ways.

containerd does a bit of a hybrid: directory is a full registry, but tag->manifest-hash is in the boltdb.

Let's get this working with the hash required, as is, and then let's deal with supporting hash-less - both in buildkit and in buildx - as a separate iteration.

@deitch
Copy link
Contributor Author

deitch commented Jun 20, 2022

Most things resolved, one open to be sure that this is right, another subject to discussion.

build/build.go Outdated Show resolved Hide resolved
@deitch
Copy link
Contributor Author

deitch commented Jun 22, 2022

Fixed the listing issue, and rebased on master to resolve conflicts. That seems to have opened up go mod hell. Hopefully won't be too bad to fix.

@deitch
Copy link
Contributor Author

deitch commented Jun 22, 2022

Fixed the go mod issues. Phew.

I am seeing vet issues with:

# github.com/docker/buildx/bake
bake/bake.go:885:69: cannot use os.Stderr (variable of type *os.File) as type *configfile.ConfigFile in argument to authprovider.NewDockerAuthProvider
# github.com/docker/buildx/bake
vet: bake/bake.go:885:69: cannot use os.Stderr (variable of type *os.File) as *configfile.ConfigFile value in argument to authprovider.NewDockerAuthProvider

I didn't think I changed those, but perhaps downstream dependencies?

@deitch deitch marked this pull request as ready for review June 22, 2022 19:38
@deitch
Copy link
Contributor Author

deitch commented Jun 22, 2022

Yeah, it looks like the definition of github.com/moby/buildkit/session/auth/authprovider.NewDockerAuthProvider() changed in buildkit from:

func NewDockerAuthProvider(stderr io.Writer) session.Attachable {
	return &authProvider{
		config:      config.LoadDefaultConfigFile(stderr),
		seeds:       &tokenSeeds{dir: config.Dir()},
		loggerCache: map[string]struct{}{},
	}
}

to

func NewDockerAuthProvider(cfg *configfile.ConfigFile) session.Attachable {
	return &authProvider{
		authConfigCache: map[string]*types.AuthConfig{},
		config:          cfg,
		seeds:           &tokenSeeds{dir: config.Dir()},
		loggerCache:     map[string]struct{}{},
	}
}

I got it.

@deitch deitch force-pushed the oci-layout-support branch 2 times, most recently from 8dba3d4 to faad929 Compare June 23, 2022 04:51
@deitch
Copy link
Contributor Author

deitch commented Jun 23, 2022

Figured out the failing CI test, updated, should be good now.

@deitch
Copy link
Contributor Author

deitch commented Jun 28, 2022

How do we stand here @tonistiigi ?

@deitch deitch force-pushed the oci-layout-support branch 2 times, most recently from 2777474 to 068c31c Compare July 17, 2022 08:36
@deitch
Copy link
Contributor Author

deitch commented Jul 17, 2022

Been almost a month. I just rebased.

Is there anything else we need to get this merged in?

@@ -126,6 +126,30 @@ FROM alpine
COPY --from=project myfile /
```

Source an image from a local [OCI layout compliant directory](https://github.com/opencontainers/image-spec/blob/main/image-layout.md):
Copy link
Member

Choose a reason for hiding this comment

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

Update line 109 with OCI layout directory and add an intented subtitle for OCI layout for the new content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Back to you @tonistiigi

Signed-off-by: Avi Deitcher <avi@deitcher.net>
@tonistiigi tonistiigi merged commit bea1ac2 into docker:master Jul 19, 2022
@crazy-max crazy-max added this to the v0.9.0 milestone Jul 19, 2022
@deitch deitch deleted the oci-layout-support branch July 19, 2022 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants