Build docker image with jetty – when should I build?
Here the Dockerfile:
FROM jetty:9.3-jre8 ADD ./grobid-home/target/grobid-home-0.4.1-SNAPSHOT.zip /opt RUN unzip /opt/grobid-home-0.4.1-SNAPSHOT.zip -d /opt && \ rm /opt/grobid-home-0.4.1-SNAPSHOT.zip && \ apt-get update && apt-get -y --no-install-recommends install libxml2 COPY ./grobid-service/target/grobid-service-0.4.1-SNAPSHOT.war \ /var/lib/jetty/webapps/ROOT.war
The current docker image works perfectly, but it requires the application to be built before (it cannot be built from the fresh git clone).
For example I could not run a build with the docker HUB build system.
What would be the prefereable approach? Build the maven project while building the image or run docker after the build as been successfully finished?
One Solution collect form web for “Build docker image with jetty – when should I build?”
I assume the docker image you are creating is for production.
If you create an image which takes the sources and build the war, you will have to embed :
- The JDK
- Your sources
Each of these are completely useless and take a lot of space in your image for absolutely nothing.
So yeah, IMO you only add the war to your docker image, you don’t build from within.
I think that you should not build your docker image inside your maven process, it’s two separate processes that you can automate with some higher level scripting (or jenkins pipeline)