Set the archive-mirrors field in the opam config
The issue at hand is that these "base images" use the opam-repository from a git remote, and thus don't use the very nice opam.ocaml.org source archive cache.
Now, since opam 2.2 we can set the archive-mirrors variable (globally) for an opam installation by:
opam option --global archive-mirrors="https://opam.ocaml.org/cache"
If somewhere in this pile of code, where opam 2.2 is likely used anyways (isn't it?), we would set the archive-mirrors, magically all the request timeout and quota exceeded / temporary download failures would vanish.
Unfortunately my knowledge of docker and these base images is not mature enough to point at the code to embed such a line. But if all works well, this would massively reduce temporary CI failures. so please consider this.
//cc @shonfeder
FWIW, related is this PR on opam2web https://github.com/ocaml-opam/opam2web/pull/242
There's been some discussion on https://github.com/ocaml/opam-repository/pull/27987 and a blog article at https://www.tunbury.org/opam2web/ @mtelvers
From that issue:
I wrote:
Would it make sense to add this to the "docker base images", so that not every user thereof has to adjust their pipelines?
Mark replied:
We are in danger of hijacking this thread, but I don't think we can add it to the Docker base images as these default to opam 2.0, and the option is an opam 2.2 feature. Also, the OP may not be using these base images.
I am not entirely sure what Mark's concern is. As far as I know, the archive-mirrors field in the global ~/.opam/config is available since 2.0 (this commit here introduced it https://github.com/ocaml/opam/commit/cfa4e77b49d0bccaf5c91b2e6f36089aab5e0540). The CLI option is only available since opam 2.2. But you could instead of running
opam option --global 'archive-mirrors+="https://opam.ocaml.org/cache"'
execute
echo "archive-mirrors="https://opam.ocaml.org/cache" >> ~/.opam/config
in your Docker base images. This would be well received by all opam >= 2.0.0 versions.
Also, the OP may not be using these base images.
I'm not sure I understand your reasoning, just because someone/something doesn't use the "docker-base-images", you don't want to improve them?
Please feel free to ignore and close this issue, especially if there are concerns. I don't know much about "ocurrent", neither about "docker" or "docker-base-images" -- I just try to understand why such a simple change that would make the life of lots of people much better is rejected (with reasons I do not understand).
Thanks for reading and have a nice day.
I am not entirely sure what Mark's concern is. As far as I know, the
archive-mirrorsfield in the global~/.opam/configis available since 2.0 (this commit here introduced it ocaml/opam@cfa4e77). The CLI option is only available since opam 2.2.
Ha ha—my concern is that in the initial description, there was the implication that the archive mirror was a 2.2 feature: "since opam 2.2, we can set the archive-mirrors." I read this to mean that the mirroring feature was added in 2.2, not that only the command line option was added in 2.2.
Also, the OP may not be using these base images.
I'm not sure I understand your reasoning, just because someone/something doesn't use the "docker-base-images", you don't want to improve them?
This comment is related to the original thread. I was initially giving general advice on how the OP could update their CI pipeline. We morphed that thread into a discussion about the base image builder. We can definitely make this change, but it hasn't been done due to the misunderstanding above.