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

dockerfile2llb: support ADD git:// with git source op #775

Closed
AkihiroSuda opened this issue Jan 8, 2019 · 12 comments · Fixed by #2799
Closed

dockerfile2llb: support ADD git:// with git source op #775

AkihiroSuda opened this issue Jan 8, 2019 · 12 comments · Fixed by #2799

Comments

@AkihiroSuda
Copy link
Member

@tonistiigi Is this intentionally left unimplemented?

@tonistiigi
Copy link
Member

What git:// URL support do you mean? git context should work an use git source op. (although it doesn't seem to be implemented 100% correct yet moby/moby#38254)

@AkihiroSuda
Copy link
Member Author

I meant ADD git:// URL

@AkihiroSuda AkihiroSuda changed the title dockerfile2llb: support git:// URL with git source op dockerfile2llb: support ADD git:// with git source op Jan 8, 2019
@tonistiigi
Copy link
Member

I don't think old builder supports it, right? This has not been added as a new feature. If you find it useful we can discuss it (and maybe use the experimental branch for it). Not sure I have an opinion myself atm. I think FROM git:// might be more useful.

@FernandoMiguel
Copy link
Collaborator

I don't personally have a use case for this, but
ADD sounds far more logical to me than FROM

OTOH, COPY vs ADD is already confusing enough.
If FROM becomes similar, we should really move down to just one 😅

@thaJeztah
Copy link
Member

thaJeztah commented Jan 8, 2019

At some point the ADD instruction was marked for deprecation because it did too much magic (remote sources, automatically extracting archives (but only if local) and such), which can be confusing, and doesn't provide a great amount of control by the user. I'm not sure if ADD git:// would be the best approach.

Some thoughts I've been playing with;

COPY --from=git://... /some/file /somewhere
COPY --from=https://... /some/file /somewhere

Last one may be tricky; what if the URL specified in --from specifies a single file? Guess we just produce an error.

Slightly off-topic, but another thing I was thinking about is to allow mounting remote sources:

RUN --mount type=remote,src=git://...,dest=/somewhere
RUN --mount type=remote,src=https://...,dest=/somewhere

The above would fetch the remote content, and mount it at /somewhere (dest). This would allow, for example:

RUN --mount type=remote,src=https://download.docker.com/linux/static/stable/x86_64/docker-18.09.0.tgz,dest=/temp/ \
  tar -xzf /temp/docker-18.09.0.tgz --strip 1  -C /usr/local/bin docker/docker

@FernandoMiguel
Copy link
Collaborator

COPY --from=git://... /some/file /somewhere
COPY --from=https://... /some/file /somewhere

I like this!

but how do you deal with auth?

@thaJeztah
Copy link
Member

Good one; didn't really give that much thought yet ☺️ - suggestions welcome 👍

@tonistiigi
Copy link
Member

Slightly off-topic, but another thing I was thinking about is to allow mounting remote sources:

If we have FROM git:// you can already mount them automatically.

FROM git:// as mygitstage
FROM alpine
RUN --mount=target=/dest,from=mygitstage cmd

The advantage is that you can now use ARG to switch between the different source location.

@tonistiigi
Copy link
Member

but how do you deal with auth?

For git we can do automatic ssh auth (like the ssh forwarding support for RUN). For https I don't think it makes sense to complicate this with one specific form of auth. You can always do the same things with an extra stage running curl and mount secrets into that stage for any type of authentication.

@FernandoMiguel
Copy link
Collaborator

Slightly off-topic, but another thing I was thinking about is to allow mounting remote sources:

If we have FROM git:// you can already mount them automatically.

FROM git:// as mygitstage
FROM alpine
RUN --mount=target=/dest,from=mygitstage cmd

The advantage is that you can now use ARG to switch between the different source location.

ohhhh wow

@thaJeztah
Copy link
Member

If we have FROM git:// you can already mount them automatically.

True, but I do find that construct a bit confusing, as in; FROM git:// is roughly the equivalent of;

FROM scratch
ADD git://... /

So that stage won't be a functional stage (unless git://... provides a rootfs. I agree that the advantage is that ARG can be used (flags currently don't handle variable substitution), but idk, it feels a bit odd to use FROM just to fetch the source, only to use it for --mount later on.

@tonistiigi
Copy link
Member

So that stage won't be a functional stage (unless git://... provides a rootfs

Not sure what you mean by that. As there are millions of ways to have a nonfunctional stage if you use wrong commands. And nothing is stopping the user from making the files in git to be functional.

Perhaps I was not clear that by having FROM git:// is automatically means that COPY --from=git:// works as well if you are not using stage names/args as FROM and COPY --from take the same arguments. As do the mounts as this also works already:

#syntax=docker/dockerfile:experimental
from alpine
run --mount=from=busybox,target=/busybox ls -l /busybox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants