usr2508
usr2508

Reputation: 81

Create war file and deploy in tomcat using Dockerfile

I have maven project which on build creates a war file. Once war is deployed, the REST url is exposed. Is it possible to create war file within Dockerfile?xxx.war This is my Dockerfile:

FROM tomcat:7.0
 
ADD "./xxx.war" /usr/local/tomcat/webapps/xxx.war
 
ENV TZ=America/Los_Angeles
 
EXPOSE 8080

Please suggest.

Thanks in advance.

Upvotes: 1

Views: 1662

Answers (1)

Sumit
Sumit

Reputation: 940

You can use multi stage dockerfile, like this:

FROM maven:3.5-jdk-8 as BUILD COPY src /usr/src/myapp/src COPY pom.xml /usr/src/myapp RUN mvn -f /usr/src/myapp/pom.xml clean package

FROM tomcat:7.0 COPY --from=BUILD /usr/src/myapp/target/xxx.war /usr/local/tomcat/webapps/xxx.war ENV TZ=America/Los_Angeles EXPOSE 8080

Upvotes: 3

Related Questions