Repository navigation
Container: add various config-related APIs - #3219
Conversation
👷 Deploy request for cloak-docs pending review.Visit the deploys page to approve it
|
e74d952 to
cd7a63a
Compare
note: this needed some trickery to make sure the shim is able to write
to /dagger/{stdout,stderr,exitCode}. the strategy is to use llb.Mkdir to
create a world-writable directory and then mount that to /dagger instead
of just llb.Scratch.
Signed-off-by: Alex Suraci <[email protected]>
also respects entrypoint if configured in image Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
cd7a63a to
d0df5a2
Compare
Signed-off-by: Alex Suraci <[email protected]>
aluzzardi
left a comment
There was a problem hiding this comment.
LGTM
One small spec nit, nothing to do with the implementation
| require.NoError(t, err) | ||
|
|
||
| testRef := "127.0.0.1:5000/testimagepush:latest" | ||
| testRef := core.ContainerAddress("127.0.0.1:5000/testimagepush:latest") |
There was a problem hiding this comment.
nit (on the spec, not the implementation): I think this should be a string rather than a scalar. Scalars define new types and are mostly useful for things that are "passthrough" to the client (e.g. an ID, which the user is supposed to retrieve and pass to another query, not create manually).
Container addresses however are "manually" entered by the user and I think having a scalar is not helping (and the user needs to do casting in their code to use it)
There was a problem hiding this comment.
I'm inclined to agree. Opened #3257 for reaching consensus on this.
sipsma
left a comment
There was a problem hiding this comment.
I think we should add the numeric uid test (here or follow-up), but otherwise LGTM!
| "directory": router.ErrResolver(ErrNotImplementedYet), | ||
| "user": router.ErrResolver(ErrNotImplementedYet), | ||
| "withUser": router.ErrResolver(ErrNotImplementedYet), | ||
| "user": router.ToResolver(s.user), |
There was a problem hiding this comment.
We should make follow ups for withGroup and withSupplementaryGroup(s). Not blocking at all for this PR of course or even that high priority, just something we'll want eventually.
I just noticed that buildkit LLB is missing those though. So we'd have to either contribute upstream (ideal) or implement it via the shim (less ideal but fine if needed).
There was a problem hiding this comment.
This might actually work as-is, since it looks like the OCI config spec has it embedded in the User field like user:group:
Not sure about supplementary groups though.
I'll add a test for this along with setting numeric UID/GID.
There was a problem hiding this comment.
You're right, good catch, this also just reignited a memory that I at one point had to deal with all this in old dagger, so I apparently knew about the user:group thing at one point and forgot: #2542 😂
Supplementary groups are fine to be missing for now I think; the use cases become much more obscure with them (wheel and various ones for devices like gpu and kvm are what I'm aware of, but that's just not important for us right now).
| // create /dagger mount point for the shim to write to | ||
| llb.AddMount( | ||
| metaMount, | ||
| // because the shim might run as non-root, we need to make a |
There was a problem hiding this comment.
Just a note: I'm actually not sure whether we'd really want the shim to run as the same user in the long run. Some of the ideas we have for it in the future involve networking stuff that might require root in the network namespace.
This is totally fine for now since updating the shim to do setuid is a lot more work and this implementation is not breaking anything now. Just wanted to bring it up for future thought. cc @aluzzardi
| container { | ||
| from(address: "alpine:3.16.2") { | ||
| user | ||
| withUser(name: "daemon") { |
There was a problem hiding this comment.
Can we add a test that this works with numeric uids too? It will still be a string type but like "123".
I double checked and believe that is what buildkit supports underneath many layers, so worth checking it works for us up here too: https://github.com/sipsma/buildkit/blob/61307b8f2e73d681721b51856c10cb8606e5ea70/executor/oci/user.go#L20-L20
There was a problem hiding this comment.
Using numeric IDs works, but I'm not fully onboard with supporting it since relying on numeric IDs feels a little brittle, and the parameter is called name. Is there a use case for sticking with numeric IDs?
There was a problem hiding this comment.
Yeah use of a non-numeric name requires the presence of /etc/passwd (which buildkit reads to map the name to a UID), which not all images have (minimal ones that just contain static binaries for instance). Also sometimes you don't want a dependency on /etc/passwd (which can change from base image to base image) and want to just have a consistent UID setting across many possible base images.
|
@vito I just thought of a couple things while reviewing the other PR related to image push:
|
Interesting - I wonder why people want to export cache mounts. 🤔 IMO this is a major feature since it lets you push tiny images built using large intermediate layers that are mounted in and then discarded. A lot of Dockerfiles do this with a complicated multi-stage + copying scheme, so it's kind of neat that Dagger makes it feel more natural. But it should absolutely be documented and framed as such. I've opened #3260 to track this. To your point, we may need to support intentionally copying a
Good point. Am I right that this will only be a concern once we implement |
Ah yes, I thought we already implemented that for some reason, but it's not an issue until that possibility exists.
Yeah I guess it would be the same as
Pretty sure they were using python or nodejs and wanted to include the package cache with the image. Whether that's really a good idea or not is a different question :-) |
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
3cf93da to
7f414c3
Compare
|
@sipsma Ready for another look! (Assuming tests pass...) Main differences:
Opened #3264 for this
Ah that makes sense, since those might be runtime dependencies. They probably want to vendor them but also not have to fetch them from scratch on every build. |
part of #3183
based on #3217 which is based on #3205 - will rebase after both are mergedrebased oncloakso it's independent nowImplements the following APIs:
note: this also means an image's
USERandENTRYPOINTare now respected.