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:

  • How to build an image with Dockerfile in Kitematic?
  • Proxy request through Apache host to docker container
  • Boot2Docker Start up fails
  • Unable to pull google/appengine-go docker image
  • Docker run command from git repo?
  • How to pass the Docker CLI Arguments when starting a container using Kubernetes
  • 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?

  • docker-compose doesn't build image from latest commit of git repository
  • Rails controller caching when using docker container (dev)
  • Stage, release and production server docker containers in single VPS
  • Docker nginx-proxy : proxy between containers
  • Issues with docker 1.2
  • Docker-compose container ports not working
  • 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.