Docker multistage build : Build maven project and deploy the artifact to wildfly image

  docker, dockerfile, maven, wildfly

I am new to docker and have a question for which i am not able to find an answer.

I want to build a maven project inside docker and deploy the artifact to wildfly on docker

My Project is a multi layer project with one parent and multiple child projects. One of the child projects creates the ear which i need to deploy on wildfly container

I am able to achieve the first step of building the maven project for which my Dockerfile entry is as below

FROM maven:3.6.0-jdk-11-slim AS Build

COPY ./parent/pom.xml ./pom.xml
COPY ./parent/utility/pom.xml ./utility/pom.xml
COPY ./parent/api/pom.xml ./api/pom.xml
COPY ./parent/impl/pom.xml ./impl/pom.xml
COPY ./parent/web/pom.xml ./web/pom.xml
COPY ./parent/web/src/main/webapp/WEB-INF/web.xml ./web/src/main/webapp/WEB-INF/web.xml
COPY ./parent/ear/pom.xml ./ear/pom.xml

RUN mvn dependency:go-offline package -B

COPY ./parent/src ./src
COPY ./parent/utility/src ./utility/src
COPY ./parent/api/src ./api/src
COPY ./parent/impl/src ./impl/src
COPY ./parent/web/src ./web/src
COPY ./parent/ear/src ./ear/src

RUN mvn package

This creates an image (of the whole project i guess). How to select ear from the target of ear project inside the image and deploy it to wildfly on container

FROM jboss/wildfly:latest As Deploy

The reason i am trying to achieve this is, i need to do a similar thing in AWS (which again i am new to).

This is a J2EE legacy app with EJB’s and struts(Hence EAR creation)

Please guide me

Source: Docker Questions