Maven + Docker

一、设置POM.xml

<build>
  <finalName>ROOT</finalName>
  <plugins>
   <plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <executions>
     <execution>
      <id>build-image</id>
      <phase>package</phase>
      <goals>
       <goal>build</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <dockerDirectory>${project.basedir}/docker</dockerDirectory>
     <imageName>${project.artifactId}:${project.version}</imageName>
     <imageTags>
      <imageTag>latest</imageTag>
     </imageTags>
     <resources>
          <resource>
            <targetPath>/</targetPath>
            <directory>${project.build.directory}</directory>
            <include>ROOT.war</include>
          </resource>
        </resources>
    </configuration>
   </plugin>
  </plugins>
 </build>

二、在工程下创建一个docker目录

 

三、在docker目录下创建文件Dockerfile,如

FROM java:7
MAINTAINER kingsy <kingsylin@vip.qq.com>

ENV TOMCAT_VERSION apache-tomcat-7.0.75

ADD ${TOMCAT_VERSION}.tar.gz /

WORKDIR /${TOMCAT_VERSION}

# INSTALL TOMCAT
RUN rm -rf webapps/*

# Add WAR
ADD ROOT.war webapps/

# RUN
CMD ["./bin/catalina.sh", "run"]

EXPOSE 80
EXPOSE 443

 

posted @ 2017-02-17 19:49  kingsy.lin  阅读(1215)  评论(0编辑  收藏  举报