I am working on improving the build system for a very large project that deploys using docker images and am unsure what the "best solution" is for something.
Our current solution is a completely custom build system that manually parses Dockerfile’s and executes them line by line by calling the docker CLI. This has a TON of disadvantages, but most notably, it means that we do things that aren’t technically valid for a standard Dockerfile.
For example, we do crazy things like copying files from outside the build context and mounting volumes during the build phase.
My plan is to refactor the Dockerfiles to only do things that are valid in "real docker" so that we can replace our build system with something more conventional in the long run.
The project is multi-language, but I am focusing on the Java portions at the moment
Our source code is divided up into small libraries where siblings often depend on each other. Something like this:
src/ ├── library1/ │ └── Library1.java ├── library2/ │ └── Library2.java ├── library3/ │ └── Library3.java ├── app1/ │ └── Main.java (depends on just Library1) ├── app2/ │ └── Main.java (depends on Library3) └── app3/ └── Main.java (depends on Library1, and Library2)
This is just an illustration. So what I’d like to do, is build
.jar files for each library in docker because I’d like to not build in the source tree and I don’t want to impose that java is installed on the host OS.
So what’s the best approach here? We have something like 30 Libraries, so I don’t want to create 30 images… I suppose I could create a "builder" image and run that as a container on each library, but where do I put the resultant
.jar files so they are accessible to the applications during their build times? Am I doomed to have to make scripts to copy the
.jar files in the app build contexts so they can be
COPYed into the build phases of the apps?
There’s gotta be a better way.. right? Am I missing something?
Right now, my craziest idea is to make a custom build context
.tgz that has the app directory AND the
.jar files added to it and then call docker with THAT… but that just seems CRAZY.
Source: Docker Questions