Curious how people build and distribute their OCaml apps
For example, do you
include the source code (like FrameworkBenchmarks/opium.dockerfile at master · TechEmpower/FrameworkBenchmarks · GitHub)
- copy the source code
- distribute the resulting image
or do you use delete the source code?
or do you do something like this FrameworkBenchmarks/aspcore-mvc-dap-pg-up.dockerfile at master · TechEmpower/FrameworkBenchmarks · GitHub :
- copy the source code to one image
- copy the build to another image
to both not distribute the source code and keep the image as small as possible?
I’m not distributing anything publicly with Docker images, but for internal work projects we use the second approach. First a build stage, then copy the compiled binary + any runtime dependencies to a more minimal runtime image. Multistage builds thankfully make this pretty straightforward, as shown in the example you linked to.
That said, including the a complete suite of build and development dependencies in an image can be very helpful to share a consistent build environment with other developers or across systems.
The last option for our work with ocaml-ci see ocaml-ci/Dockerfile at master · ocurrent/ocaml-ci · GitHub and GitHub - ocurrent/ocaml-ci: A CI for OCaml projects
- Lines 1 - 34 do the setup, copy and building
- Lines 34 - 55 produce an image
- That image gets uploaded to hub.docker.com as Docker Hub