Permalink
Browse files

add docker to maven build to build docker image from spring boot jar

  • Loading branch information...
jimbasilio committed Dec 30, 2015
1 parent 89e7944 commit 1d648ce45fdd86f89c1c0fedef40b9fc8832a0fa
View
@@ -5,3 +5,4 @@ bin/*
npm-debug.log
bower_components
/target/
nohup.out
View
45 pom.xml
@@ -14,7 +14,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.Rc1</version>
<version>1.3.1.RELEASE</version>
</parent>
<dependencies>
@@ -74,8 +74,6 @@
</dependency>
</dependencies>
<!-- in the m2e profile, insert a default for the build timestamp b/c sts/eclipse
doesn't fill in the build timestamp -->
<!-- when building from commandline (i.e. mvn) this fills in correctly. -->
<profiles>
<profile>
@@ -85,9 +83,6 @@
<name>m2e.version</name>
</property>
</activation>
<properties>
<maven.build.timestamp>UNKNOWN</maven.build.timestamp>
</properties>
</profile>
</profiles>
@@ -106,27 +101,37 @@
<build.version>${project.version}</build.version>
<docker.image.prefix>jimbasilio</docker.image.prefix>
<!-- in the m2e profile, insert a default for the build timestamp b/c sts/eclipse
doesn't fill in the build timestamp -->
<maven.build.timestamp>UNKNOWN</maven.build.timestamp>
</properties>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/milestone</url>
</repository><repository>
<id>spring-milestones-libs</id>
<name>Spring Lib Milestones</name>
<url>http://repo.spring.io/libs-milestone/</url>
</repository>
</repositories>
<build>
<plugins>
<!-- Package as a docker image -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.2.3</version>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
<!-- Package as an executable jar -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- BEGIN REMOVE ONCE SPRING BOOT RELEASED -->
<version>1.2.6.RELEASE</version>
<!-- END REMOVE ONCE SPRING BOOT RELEASED -->
<executions>
<execution>
<goals>
@@ -0,0 +1,5 @@
FROM java:8
VOLUME /tmp
ADD com.basilio.hiit-0.0.1-SNAPSHOT.jar hiit.jar
RUN bash -c 'touch /hiit.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=hsqldb","-jar","/hiit.jar"]
@@ -3,6 +3,7 @@
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@@ -12,6 +13,7 @@
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@Rollback(true)
@ActiveProfiles("hsqldb")
public abstract class BaseIntegrationTest {
}
@@ -4,14 +4,12 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.basilio.hiit.dto.ProgramDTO;
import com.basilio.hiit.service.ProgramService;
@RunWith(SpringJUnit4ClassRunner.class)
@Rollback(true)
public class ProgramServiceTest extends BaseIntegrationTest {
@Autowired
@@ -21,7 +19,7 @@
public void testStore() {
ProgramDTO toSave = new ProgramDTO();
toSave.setName("test program");
toSave.setIterations(10);
toSave.setIterations(5);
Long newId = sut.store(toSave);

0 comments on commit 1d648ce

Please sign in to comment.