Skip to content

Commit b96e109

Browse files
committed
Add a Dockefile and configure the docker-maven-plugin
1 parent 8645807 commit b96e109

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

pom.xml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.springframework.samples</groupId>
66
<artifactId>springboot-petclinic</artifactId>
7-
<version>1.4.0-SNAPSHOT</version>
7+
<version>1.4.0</version>
88
<parent>
99
<groupId>org.springframework.boot</groupId>
1010
<artifactId>spring-boot-starter-parent</artifactId>
@@ -19,6 +19,7 @@
1919
<java.version>1.7</java.version>
2020
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2121
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
22+
<docker.image.prefix>arey</docker.image.prefix>
2223

2324
<!-- Dates -->
2425
<jodatime-hibernate.version>1.3</jodatime-hibernate.version>
@@ -313,6 +314,28 @@
313314
</execution>
314315
</executions>
315316
</plugin>
317+
<plugin>
318+
<groupId>com.spotify</groupId>
319+
<artifactId>docker-maven-plugin</artifactId>
320+
<version>0.4.11</version>
321+
<configuration>
322+
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
323+
<dockerDirectory>src/main/docker</dockerDirectory>
324+
<resources>
325+
<resource>
326+
<targetPath>/</targetPath>
327+
<directory>${project.build.directory}</directory>
328+
<include>${project.build.finalName}.war</include>
329+
</resource>
330+
</resources>
331+
<forceTags>true</forceTags>
332+
<imageTags>
333+
<imageTag>${project.version}</imageTag>
334+
<imageTag>latest</imageTag>
335+
</imageTags>
336+
<useConfigFile>true</useConfigFile>
337+
</configuration>
338+
</plugin>
316339
</plugins>
317340
</build>
318341
<reporting>

src/main/docker/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM openjdk:alpine
2+
MAINTAINER Antoine Rey <antoine.rey@free.fr>
3+
# Spring Boot application creates working directories for Tomcat by default
4+
VOLUME /tmp
5+
ADD petclinic.war petclinic.war
6+
RUN sh -c 'touch /petclinic.war'
7+
# To reduce Tomcat startup time we added a system property pointing to "/dev/urandom" as a source of entropy.
8+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/petclinic.war"]

0 commit comments

Comments
 (0)