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.
您可以使用多阶段dockerfile
,如下所示:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.