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:

  • Does docker CMD carry on from upper images to be passed as argument to ENTRYPOINT
  • Docker log file not created
  • Remote communication with private docker registry issues
  • docker-proxy getting accept4: bad file descriptor
  • Assign public IP to docker
  • Docker-compose on Windows 7: how to import a db dump when using a yaml file?
  • 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?

  • How to merge two running Docker Containers?
  • Docker environmental variables sharing
  • Docker image creation exception: “This archives contains unclosed entries”
  • Debian Host: CTRL + P + Q doesn't keep container alive
  • Build and use docker image from docker-compose
  • Jackrabbit with PostgreSQL backend leaves repository in inconsistent state
  • 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.