-
Notifications
You must be signed in to change notification settings - Fork 22
Support RUN command arguments (mounts, network, security)
#139
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
Conversation
|
@edwintorok I had not read your proposal carefully enough, do you already have code to achieve this? What do you think of this proposal? |
|
My code is currently here master...edwintorok:ocaml-dockerfile:caching. I'm not entirely happy with how the API on that looks, and still evolving it as I use it. |
|
Crunching mounts: I'm undecided what the best way forward is. Crunching commands with different mounts, especially with 'sharing=locked' might result in the build holding the lock for way longer than intended (small individual commands may be faster here even if they create additional layers). |
I think I can rebase my changes on top of yours, in some areas they are more complete than mine. I have a few more things on my branch (caching support in opam package manager, but that builds on top of this, and some doc comments, and a convenient value for the correct parsing_directive to use). |
|
Crunching is already super fragile: is assumes a Unix shell-like syntax. I think we had an issue for something like this but I can't remember where it is. Anyway, I don't use crunch too much in Windows code, it behaves poorly with line continuations,
Cool! |
|
as long as the mounts are identical I think crunch should accept it (and be careful so we end up just with one set of mounts), otherwise either eject it or silently skip over it. Rejecting sounds better because it wouldn't break user expectations. Yes crunching is already quite fragile if you e.g. 'cd' in one RUN line then the next one will run in a different directory. That may or may not be what the user wanted. It is useful to be able to run on small portions of the dockerfile, but when mounts are used I don't think that running it on the entire one would be useful. |
|
I've simplified the code, I think. I've added your |
|
Thanks, I have some additional code to use this, I'll rebase it on top of your latest branch. |
|
run-args...edwintorok:ocaml-dockerfile:caching-run-args There are some commits there that you may want to cherry-pick into this PR: In particular escaping is important because 'space' is otherwise a separator between mount args, but it may also show up inside mount args (e.g. a cache id, or a directory path, though in general on Linux paths don't have spaces that is not a reason to not implement escaping). And I think the buildkit_syntax commit from above would also fix the ocaml-lint failure that ocaml-ci is complaining about here. I've also written a test that generates a single dockerfile with all opam containers and builds them in parallel, but I'll open a separate PR with that (it is in my branch above), and the rest of the changes (to use caching for apt/yum/opam commands/etc.) |
Signed-off-by: Edwin Török <edwin.torok@cloud.com>
The official docs are quite scarce on how these work, add a few more details here to make it easier to use. Most of these work with both Docker and Podman 4.x, some options are only supported by Docker, and some options are parsed but do not work on older versions of Podman. Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Space is the separator between mount args, and if some mount arg contains a space (e.g. a cache id, or directory) then we must escape it. Signed-off-by: Edwin Török <edwin.torok@cloud.com>
The caching part is super cool, that would be a great feature IMO. Thank you for the other commits, I've cherry-picked them (rebasing with the format fix, which changed the commit id). I'm all in for escapes, so I've included your patch. |
|
Additional tests would be most welcome, especially on the escaping spaces.
…On Sat, 18 Feb 2023 at 4:33 am, Török Edwin ***@***.***> wrote:
run-args...edwintorok:ocaml-dockerfile:caching-run-args
<run-args...edwintorok:ocaml-dockerfile:caching-run-args>
There are some commits there that you may want to cherry-pick into this PR:
2dcbb8e
<2dcbb8e>
Dockerfile: escape spaces in mount args
45dac5c
<45dac5c>
Dockerfile.mli: more documentation on mounts
fe66805
<fe66805>
Dockerfile: refer to {!buildkit_syntax}
In particular escaping is important because 'space' is otherwise a
separator between mount args, but it may also show up inside mount args
(e.g. a cache id, or a directory path, though in general on Linux paths
don't have spaces that is not a reason to not implement escaping).
I've also written a test that generates a single dockerfile with all opam
containers and builds them in parallel, but I'll open a separate PR with
that (it is in my branch above).
—
Reply to this email directly, view it on GitHub
<#139 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABJXOMCCA6OAPPILRQRK3TWX6ZAJANCNFSM6AAAAAAUPDJ7MI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
This looks great. Thank you.
…On Tue, 21 Feb 2023 at 9:01 am, Tim McGilchrist ***@***.***> wrote:
Additional tests would be most welcome, especially on the escaping spaces.
On Sat, 18 Feb 2023 at 4:33 am, Török Edwin ***@***.***>
wrote:
> run-args...edwintorok:ocaml-dockerfile:caching-run-args
> <run-args...edwintorok:ocaml-dockerfile:caching-run-args>
>
> There are some commits there that you may want to cherry-pick into this
> PR:
> 2dcbb8e
> <2dcbb8e>
> Dockerfile: escape spaces in mount args
> 45dac5c
> <45dac5c>
> Dockerfile.mli: more documentation on mounts
> fe66805
> <fe66805>
> Dockerfile: refer to {!buildkit_syntax}
>
> In particular escaping is important because 'space' is otherwise a
> separator between mount args, but it may also show up inside mount args
> (e.g. a cache id, or a directory path, though in general on Linux paths
> don't have spaces that is not a reason to not implement escaping).
>
> I've also written a test that generates a single dockerfile with all opam
> containers and builds them in parallel, but I'll open a separate PR with
> that (it is in my branch above).
>
> —
> Reply to this email directly, view it on GitHub
> <#139 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABJXOMCCA6OAPPILRQRK3TWX6ZAJANCNFSM6AAAAAAUPDJ7MI>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
|
CHANGES: - Install system packages required by OCaml in the ocaml stage, starting with OCaml 5.1 and libzstd. (@MisterDA ocurrent/ocaml-dockerfile#149, review by @kit-ty-kate) - Add OracleLinux 9. (@MisterDA ocurrent/ocaml-dockerfile#155) - Optimize and fix Linux package install. (@MisterDA ocurrent/ocaml-dockerfile#147, ocurrent/ocaml-dockerfile#151, ocurrent/ocaml-dockerfile#153, ocurrent/ocaml-dockerfile#154, review by @kit-ty-kate) - Switch to ocaml-opam/opam-repository-mingw#sunset for Windows images. (@MisterDA ocurrent/ocaml-dockerfile#152) - Use DockerHub user risvc64/ubuntu. (@MisterDA, ocurrent/ocaml-dockerfile#150) - Various LCU Updates (@mtelvers ocurrent/ocaml-dockerfile#144 ocurrent/ocaml-dockerfile#136 ocurrent/ocaml-dockerfile#135) - Support mounts, networks, and security parameters in RUN commands, add buildkit_syntax helper function. (@MisterDA, @edwintorok, ocurrent/ocaml-dockerfile#137, ocurrent/ocaml-dockerfile#139, review by @edwintorok) - Build and install opam master from source in Windows images. (@MisterDA ocurrent/ocaml-dockerfile#140, ocurrent/ocaml-dockerfile#142, ocurrent/ocaml-dockerfile#143) - Include the ocaml-beta-repository in the images. (@kit-ty-kate ocurrent/ocaml-dockerfile#132, review by @MisterDA) - Add OpenSUSE 15.4, deprecate OpenSUSE 15.3. (@MisterDA ocurrent/ocaml-dockerfile#138) - Update to bubblewrap 0.8.0. (@MisterDA ocurrent/ocaml-dockerfile#131 ocurrent/ocaml-dockerfile#148) - Add Alpine 3.17 (3.16 is now tier 2 and 3.15 is deprecated). Remove libexecinfo-dev from the list of apk packages as it is no longer available. Its symbols are only used in OCaml's self tests. (@MisterDA ocurrent/ocaml-dockerfile#129, ocurrent/ocaml-dockerfile#130) - Fix location of Debian exotic architecture images (@dra27 ocurrent/ocaml-dockerfile#134) - Fix passing of --platform to all stages of the Dockerfiles (@dra27 ocurrent/ocaml-dockerfile#134)
This is a first attempt at supporting
RUNcommand arguments. I've added types for mounts and networks which are in BuildKit, and security, which is not yet in BuildKit. I've added an escape hatch toRUNas the?args:string listparameter for later additions (and podman compat?). The security and network types, being relatively simple now, get their own parameters toRUN, but the mount values are serialized to string first.The
crunchfunction will not crunch shell scripts if their network or security differ, specified or not.cc #137