-
Notifications
You must be signed in to change notification settings - Fork 358
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
opam clean doesn't clean enough, especially for Docker images #4282
Comments
So, what are you actually trying to get done? I see a series of low-level requests (this and #4255) but I don't have a sense of what you're trying to accomplish at a high level. Do you want some way to generate a Dockerfile for a sequence of installs and opam remotes that is caching friendly for BuildKit layers? It would be helpful to see that description, and perhaps a few example Dockerfiles that you're currently using and that are problematic. https://github.com/ocurrent/ocaml-ci/tree/master/solver has a comprehensive domain-specific opam solver that we use to generate caching-friendly Dockerfiles for the new ocaml CI, so we may be able to pull something out of that for use by Coq as well. |
At a high level, I am trying to minimize the image size, while it seems you are trying to minimize image build time; in fact, I'm increasing build times to reduce the image size. The basic trick I learned is each
Looking at https://github.com/ocurrent/ocaml-ci suggests it's cool and it solves a real problem, but that it's orthogonal to what I'm doing; and looking at https://github.com/ocurrent/ocaml-ci/blob/master/Dockerfile suggests the produced images might be bigger than needed, since that calls neither
I think the included More in general, I just want to write by hand Dockerfiles that produce images that don't waste space — I expect those images to be updated at most once a month. I've never heard of BuildKit or Moby before this week, I still use Docker like I learned in 2014. I do try to shrink each layer. The usual advice says things like "after And yet, even after calling that, adding a 5MB executable and 25MB of extra files (my opam repository) added 200 MB to the image, because opam was saving a checkout of coq ( |
Keep going higher :-) What are you trying to do with the opam client and opam repos and Dockerfiles? Is it a Coq memoisation cache of some kind, or a CI, or something else? If you could sketch out the overall flow of images, that would be helpful. We'd rather understand the problem you're trying to solve rather than shoehorn in partial solutions to the opam client. My initial thought is that you want some way to install opam packages to look like system packages, and then get rid of opam entirely from the image. That would lose the entire ~/.opam directory, and leave the image with something that looks similar to an installation done from (e.g.) a Debian package. Note that the Dockerfiles you looked at above aren't what ocaml-ci generates; they are the Dockerfiles for ocaml-ci itself. It generates much lower level files that look like: https://ci.ocamllabs.io:8100/job/2020-07-23/092829-ci-ocluster-build-ec217b -- each layer is designed to minimise the dependencies on the source tree (so it does an incremental build in seconds if you only change source code, and not package metadata). |
@avsm The image is to be used for the CI of other Coq packages — it memoizes the "static" dependencies (the packages that don't change much, both Coq itself and coq libraries). If the image is bigger, it takes longer to download, and I was told that matters (up to a point).
Yeah I was aware; thanks for the link, but it seems yours doesn't call
That seems interesting, but our CI uses opam and assumes an opam install, and after using the
|
Thanks @Blaisorblade for the ping! |
Reviewing issues yesterday, it's not clear that there are features here for opam to add - looking at the three original items in your
Additionally, we're working on proposals for In terms of feature changes to opam, I'm going to close this, but please do re-open it if necessary. |
I'd hope that means that more of this data can be cleaned safely, instead of less? |
No, that's not the target of that piece of work. The issue from opam's perspective here is that you're not asking to "clean" the root (that would imply the files were cached), what you're doing is corrupting the root, it just so happens to be OK to do that for your use-case. For example, the Coq repos you're working with may not use any files, but this Dockerfile is not a case for allowing blessed deletion of repo clones: FROM ocaml/opam:debian-ocaml-4.12
RUN rm -rf ~/.opam/repo/*/
RUN opam reinstall ocaml-config (fails unless one first runs |
I filed #4255 before, but after more investigation, it turns out that
opam clean
leaves lots of useless caches around. I'm building Docker images, where reducing disk size is important. Here's what I use now — /cc @erikmd who might also be interested.In my new Dockerfiles, each separate
opam install
step becomesopam update <needed repos>; opam install foo; /tmp/opam-clean
, where/tmp/opam-clean
has the following contents:I realize removing the sources might in principle break remove scripts, but that folder contains sources for packages with empty remove scripts (at least
coq-iris
andcoq-stdpp
) — so there's no reason to keep them.Now, of course opam isn't entirely too happy about that —
opam install
, done as above, works just fine, but other things run into more trouble. Below is the log of some commands, showing a slightly confusedopam
— the firstopam upgrade
is expected to fail, but afteropam update
redownloads everything needed, the secondopam upgrade
gives the wrong result.The text was updated successfully, but these errors were encountered: