Hello,
currently I try to build my little Ocaml project on gitlab. I use this Image: image: ocaml/opam:debian-ocaml-5.3
But for some reasons it needs ‘pgk-config’ installed which is not in the image.
When I try to do ‘sudo apt install’ I cannot get root privileges and get nothing installed.
Is there a preconfigured ‘.gitlab-ci.yaml’ which I can use?
I don’t understand why you’re having issues with sudo in the Docker image, for me it works fine.
For instance, running docker build with the following Dockerfile works for me:
FROM ocaml/opam:debian-ocaml-5.3
RUN sudo apt update -y && sudo apt install pkg-config -y
Running interactively from ocaml/opam:debian-ocaml-5.3 and doing sudo <something> also works.
However, it’s true that the default opam version used in such images is 2.0, and it does not integrate depext. So if you try e.g. opam install efl (a package which depends on conf-pkg-config, it will indeed fail. But if you use opam-2.3 instead of opam, for instance, you should get a message such as:
opam believes some required external dependencies are missing. opam can:
> 1. Run apt-get to install them (may need root/sudo access)
2. Display the recommended apt-get command and wait while you run it manually (e.g. in another terminal)
3. Continue anyway, and, upon success, permanently register that this external dependency is present, but not detectable
4. Abort the installation
By default, it will choose 1, get sudo, install pkg-config and everything should work.
I suspect the issue might be related to your Gitlab configuration and not the Docker image itself, but more details might be needed to understand why.
In any case, I’d recommend doing something like RUN sudo ln -sf /usr/bin/opam-2.3 /usr/bin/opam to use the most recent opam by default. It may not help with sudo, but it’s still useful when using opam in general.