My problem shouldn’t be too unfamiliar for those with web development. What i’m trying to achieve is simply a full build of our application, triggered from Jenkins.
- NodeJs 10
- Java 8
My plan consists of three images:
- Build-build image: Using
FROM Java, installs NodeJs (and gradle) into that image
- Build-image: Installs npm packages and gradle dependencies, tests and compiles
- Image: Only consists of production software and build artifacts, like *.WAR, *.js.
The reasons for this plan is that there is no need to rebuild the base image (step 1) on every code change, only when we actually upgrade the Java, Node or Chromium version.
I see problems with bundling the steps into less stages.
- A: Step 2 and 3 could maybe be bundled into a multi-stage build. Then, however, I would have mixed the builder pattern with a multi-stage pipeline on top, ouch!
- B: I could do a clean rebuild
FROM scratch. This, however, would needlessly install the full V8 engine into a Java image (or vice versa) no matter how late the build fails (think of a single unit test.)
The build is also planned to become more complicated in the future, sidecar-ing a mysql-container (with the step 2 image) to check if the Backend initialized the database correctly.
So is this a normal approach, best practice or straight out of hell?