Hi,
I had a quick go at creating something with Docker: (and alpine since I was more familiar with it, but I suspect a similar technique would work with ubuntu)
It uses `opam` to build a simple OCaml example (taken from cryptokit) which needs `libgmp` at runtime. The `Dockerfile` has a slightly hacky attempt to detect the runtime dependency:
opam depext -n cryptokit | grep -v '#' | grep '\-dev' | while read in; do basename "$in" -dev; done > needed-packages.txt
It assumes that
- all external C libraries have an alpine depext called foo-dev
- foo-dev has a corresponding runtime package called foo
and installs these `foo` in an output minimal alpine image (i.e. one without the development tools or other unnecessary stuff)
Another approach would be to use `ldd` or `objdump` recursively to find libraries and copy only those binaries into the output (possibly using `FROM scratch`?)
I don't know if this will help -- I realise my test case is a bit minimal :-)
Cheers,
Dave