user840930
user840930

Reputation: 5578

how to add a war file and custom configuration to a wildfly docker image?

my war file runs on wildfly when I modify the standalone.xml adding the path to the file in a deployments section at the end of the file like the following: . .

</socket-binding-group>
  <deployments>
    <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/local/path/exploded/mywar.war"/>
    </deployment>
  </deployments>
 </server>

How can I build a docker image like this?

I started with the following:

 FROM jboss/wildfly
 ADD standalone.xml /opt/jboss/wildfly/standalone/configuration
 ADD mywar.war mywar.war

where standalone.xml has the following:

  <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/mywar.war"/>
  </deployment>

But when I run this docker image, wildfly complains:

 Caused by: java.io.FileNotFoundException: /mywar.war (No such file or directory)

How can I fix this? Where should my war go in the docker image? If I put it in deployment then wildfly complains that there is a duplicate resource.

Upvotes: 1

Views: 1643

Answers (1)

user840930
user840930

Reputation: 5578

Okay, I solved it

Here is the entry I added to standalone.xml:

<deployments>
    <deployment name="mywar.war" runtime-name="mywar.war">
        <fs-exploded path="/opt/jboss/wildfly/exploded/mywar.war"/>
    </deployment>
</deployments>

And here is the Dockerfile that worked for me:

 FROM jboss/wildfly
 ADD standalone.xml /opt/jboss/wildfly/standalone/configuration
 ADD build/libs/exploded /opt/jboss/wildfly/exploded

Upvotes: 1

Related Questions