Reputation: 5231
I have manually written dockerfile but now I need configure maven to create that file and build image. I'm trying do it with spotify's maven plugin.
Here is dockerfile which is written by me and it works:
FROM tomcat:8.0-jre8
RUN rm -rvf /usr/local/tomcat/webapps/ROOT
COPY ./context.xml /usr/local/tomcat/conf/
COPY /target/brainis-1.0-SNAPSHOT.war /usr/local/tomcat/webapps/ROOT.war
CMD ["catalina.sh", "run"]
EXPOSE 8080
I need ensure my maven plugin generate same docker file before build image. Can you tell me please how to achieve it? My current configuration generates only first command FROM tomcat:8.0-jre8
, how to configure rest of that file in maven?
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<imageName>spring-tomcat</imageName>
<baseImage>tomcat:8.0-jre8</baseImage>
</configuration>
</plugin>
Upvotes: 2
Views: 643
Reputation: 4501
You need to add your Dockerfile
to your codebase, i.e. /src/main/docker/Dockerfile
and reference it from Spotify's Maven plugin this way:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.war</include>
</resource>
</resources>
</configuration>
</plugin>
The last part, resources, places the docker build base path in whichever folder you want it, i.e. /target
and which files to include.
That will run your whole Dockerfile
script
Upvotes: 3