-
Notifications
You must be signed in to change notification settings - Fork 18
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
Install system packages required by OCaml 5.1+ in the ocaml stage #149
Conversation
be11aff
to
e5b3137
Compare
29c1b15
to
825fff1
Compare
Now based on top of #153. |
c49781b
to
747c9a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good in principle but I'm not sure why the dev_packages
function wasn't changed instead of creating a new function that users have to call manually. Is there a downside to adding a new mandatory parameter to the dev_packages
function? Is this just to allow optional dependencies to be decided by the user (if so I think the function name could be more explicit about that). I would personally be more in favour of simply adding a new mandatory parameter to dev_packages
and enforce a set of packages in an opinionated way.
The goal is really to avoid installing unneeded packages, like libx11 and all its dependencies in the shared opam image. We're going to have to call a function anyway when creating the ocaml stage. With this new function, the patch to docker-base-images is trivial: I think there would be two new parameters: one indicating whether we're in the opam or ocaml (installing the ocaml switch) stage, and the other the ocaml version (the name of the switch). IMO that's better expressed with a new function, but maybe the name could be better. Perhaps |
hmm, passing the switch in an option would work too, I'll try that. |
3d05d4e
to
360f477
Compare
src-opam/linux.ml
Outdated
match version with | ||
| None -> | ||
install | ||
"sudo passwd bzip2 unzip patch rsync nano gcc-c++ git tar curl xz \ | ||
which m4 diffutils findutils%s" | ||
extra | ||
| Some v -> | ||
if Ocaml_version.compare v Ocaml_version.Releases.v4_08 <= 0 then | ||
install "libX11-devel%s" extra | ||
else if Ocaml_version.compare v Ocaml_version.Releases.v5_1_0 >= 0 then | ||
install "zstd%s" extra | ||
else empty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was more thinking of something like this
match version with | |
| None -> | |
install | |
"sudo passwd bzip2 unzip patch rsync nano gcc-c++ git tar curl xz \ | |
which m4 diffutils findutils%s" | |
extra | |
| Some v -> | |
if Ocaml_version.compare v Ocaml_version.Releases.v4_08 <= 0 then | |
install "libX11-devel%s" extra | |
else if Ocaml_version.compare v Ocaml_version.Releases.v5_1_0 >= 0 then | |
install "zstd%s" extra | |
else empty | |
install | |
"sudo passwd bzip2 unzip patch rsync nano gcc-c++ git tar curl xz \ | |
which m4 diffutils findutils%s%s" | |
extra | |
(if Ocaml_version.compare v Ocaml_version.Releases.v4_08 <= 0 | |
then "libX11-devel" | |
else if Ocaml_version.compare v Ocaml_version.Releases.v5_1_0 >= 0 | |
then "zstd" | |
else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, but I want for instance to remove libx11
from ocaml/opam:alpine-3.17-opam
:
RUN apk update && apk upgrade
- RUN apk add build-base patch tar ca-certificates git rsync curl sudo bash libx11-dev nano coreutils xz ncurses-dev bubblewrap
+ RUN apk add build-base patch tar ca-certificates git rsync curl sudo bash nano coreutils xz ncurses-dev bubblewrap
COPY --from=0 [ "/usr/local/bin/opam-2.0", "/usr/bin/opam-2.0" ]
RUN ln /usr/bin/opam-2.0 /usr/bin/opam
COPY --from=0 [ "/usr/local/bin/opam-2.1", "/usr/bin/opam-2.1" ]
and have it installed as part of ocaml/opam:alpine-3.17-ocaml-4.02
to ocaml/opam:alpine-3.17-ocaml-4.07
:
# syntax=docker/dockerfile:1
FROM ocurrent/opam-staging:alpine-3.17-opam-amd64
ENV OPAMYES="1" OPAMCONFIRMLEVEL="unsafe-yes" OPAMERRLOGLEN="0" OPAMPRECISETRACKING="1"
+ RUN apk update && apk upgrade
+ RUN apk add libX11-dev
RUN opam switch create 4.02 --packages=ocaml-base-compiler.4.02.3
RUN opam pin add -k version ocaml-base-compiler 4.02.3
RUN opam install -y opam-depext
The function dev_packages
is called when building the first stage, so we can't test the ocaml version at this step. We could reinstall all the packages in the second step but that would be wasted work.
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also supposing that libx11 and zstd are not needed when bootstrapping opam.
As @kit-ty-kate noticed privately, removing libx11 from the -opam images might break workflows of people using them, especially for older versions of OCaml, so I've (for now) constrained this change to only installing zstd on -ocaml-5.1 (and onwards) images. |
src-opam/linux.ml
Outdated
"build-base patch tar ca-certificates git rsync curl sudo bash \ | ||
libx11-dev nano coreutils xz ncurses-dev%s" | ||
"build-base patch tar ca-certificates git rsync curl sudo bash nano \ | ||
coreutils xz ncurses-dev libX11-dev%s" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Alpine the name of packages are case sensitive
coreutils xz ncurses-dev libX11-dev%s" | |
coreutils xz ncurses-dev libx11-dev%s" |
I would also suggest to keep the same ordering as before to limit the diff and avoid such issues elsewhere
OCaml 5.1+ can optionally use libzstd for compressing marshalled data. Install this package in the ocaml image. It's not needed in the opam stage. Future work might remove uneeded packages from the opam image, like libx11 that the graphics library depends on, for OCaml 4.09+.
031c5ea
to
81386b9
Compare
Thanks for the reviews! |
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)
Different releases of OCaml require different system libraries: libX11 isn't needed since 4.09, when the Graphics library was moved from the core distribution to a separate package. On the opposite side, OCaml 5.1 can optionally use libzstd for compressing marshalled data. Install these packages accordingly in the ocaml image.