Build docker image with jetty – when should I build?

I’m working on ‘dockerizing’ a java web application (https://github.com/kermitt2/grobid) which I want to run using jetty.

Here the Dockerfile:

  • docker version fails on OS X
  • Dockerfile with nesting via non-master branches
  • Create django super user in a docker container without inputting password
  • MSSQL Server for Linux Docker Versions
  • Configuring docker to communicate over the network
  • Running Scrapy in Docker Container
  • 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?

  • How to demonize one image of a docker-compose composition?
  • tcpdump reports error in Docker container that's started with --privileged
  • where is the systemout log of websphere on docker?
  • docker-java/docker remote api block until container is finished
  • use docker exec in bash script
  • Docker On windows10 Volume permissions “ a STORAGE ENGINE failed.”
  • 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
    • Maven
    • 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)

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.