Build docker image with jetty – when should I build?

I’m working on ‘dockerizing’ a java web application ( which I want to run using jetty.

Here the Dockerfile:

  • docker run sed doesn't work
  • adding R package for installation from Github in Dockerfile
  • Deploy Docker environment on Elastic Beanstalk
  • Why the images information provided by docker info is different from docker images
  • How to get Docker container ID alone
  • Trouble connecting to a SQL Server Database through a JBoss 6 EAP docker container
  • FROM jetty:9.3-jre8
    ADD ./grobid-home/target/ /opt
    RUN unzip /opt/ -d /opt && \
        rm /opt/ && \
        apt-get update && apt-get -y --no-install-recommends install libxml2
    COPY ./grobid-service/target/grobid-service-0.4.1-SNAPSHOT.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 rm does not remove my container if the physical machine dies
  • docker-compose volumes not mounting to host directories
  • unable to run boot2docker-vm in windows
  • Containerization pattern best practice
  • Containerized server application failing to connect to MySQL databases
  • docker and jwilder/nginx-proxy http/https issue
  • 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.