Docker中部署Tomcat,并且部署Java应用程序

Dockerfile

FROM tomcat:9.0-jre8-alpine
MAINTAINER louguanyang <louguanyang@hzsuidifu.com>

VOLUME /tmp

ARG JAR_FILE

RUN apk add -U tzdata

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN echo "Asia/Shanghai" > /etc/timezone

RUN apk del tzdata

ADD ${JAR_FILE} /usr/local/tomcat/webapps

CMD ["catalina.sh", "run"]

  pom.xml

<!-- dockerfile-maven-plugin -->
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>${dockerfile-maven-plugin.version}</version>
    <executions>
        <execution>
            <id>default</id>
            <phase>package</phase>
            <goals>
                <goal>build</goal>
                <!--<goal>push</goal>-->
                <!--<goal>tag</goal>-->
            </goals>
        </execution>
    </executions>
    <configuration>
        <force>false</force>
        <repository>${docker.repository}/${docker.image.prefix}/${project.artifactId}</repository>
        <tag>${project.version}</tag>
        <buildArgs>
            <JAR_FILE>target/${project.build.finalName}.war</JAR_FILE>
        </buildArgs>
    </configuration>
</plugin>

  

posted @ 2018-09-04 22:48  楼关杨  阅读(988)  评论(0编辑  收藏  举报