Skip to content

Commit

Permalink
Centralized Docker configuration (#38) (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpaszek authored and mszarlinski committed Jan 30, 2018
1 parent 5df6e67 commit cf84ed0
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 244 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ ARG ARTIFACT_NAME
ADD ${ARTIFACT_NAME}.jar /app.jar
ENV SPRING_PROFILES_ACTIVE docker
RUN bash -c 'touch /app.jar'
EXPOSE 9090
EXPOSE ${EXPOSED_PORT}
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
40 changes: 40 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<java.version>1.8</java.version>

<docker.image.prefix>mszarlinski</docker.image.prefix>
<docker.image.exposed.port>9090</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}</docker.image.dockerfile.dir>
<docker.plugin.version>0.4.13</docker.plugin.version>
</properties>

Expand Down Expand Up @@ -125,6 +127,44 @@
</build>

</profile>

<profile>
<id>buildDocker</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>${docker.image.dockerfile.dir}</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
<EXPOSED_PORT>${docker.image.exposed.port}</EXPOSED_PORT>
</buildArgs>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>

</project>
24 changes: 2 additions & 22 deletions spring-petclinic-admin-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

<properties>
<spring-boot-admin.version>1.5.6</spring-boot-admin.version>
<docker.image.exposed.port>9090</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
Expand Down Expand Up @@ -63,28 +65,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
24 changes: 2 additions & 22 deletions spring-petclinic-api-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<webjars-angular.version>1.6.4</webjars-angular.version>
<webjars-angular-ui-router.version>1.0.3</webjars-angular-ui-router.version>
<wro4j.version>1.8.0</wro4j.version>
<docker.image.exposed.port>8081</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
Expand Down Expand Up @@ -149,28 +151,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
10 changes: 0 additions & 10 deletions spring-petclinic-api-gateway/src/main/docker/Dockerfile

This file was deleted.

27 changes: 5 additions & 22 deletions spring-petclinic-config-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<version>1.5.9</version>
</parent>

<properties>
<docker.image.exposed.port>8888</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
<!-- Spring Boot -->
<dependency>
Expand Down Expand Up @@ -45,28 +50,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
7 changes: 0 additions & 7 deletions spring-petclinic-config-server/src/main/docker/Dockerfile

This file was deleted.

27 changes: 5 additions & 22 deletions spring-petclinic-customers-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<version>1.5.9</version>
</parent>

<properties>
<docker.image.exposed.port>8081</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
<!-- Petclinic -->
<dependency>
Expand Down Expand Up @@ -94,28 +99,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
10 changes: 0 additions & 10 deletions spring-petclinic-customers-service/src/main/docker/Dockerfile

This file was deleted.

27 changes: 5 additions & 22 deletions spring-petclinic-discovery-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<version>1.5.9</version>
</parent>

<properties>
<docker.image.exposed.port>8761</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
<!-- Spring Boot -->
<dependency>
Expand Down Expand Up @@ -43,28 +48,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
10 changes: 0 additions & 10 deletions spring-petclinic-discovery-server/src/main/docker/Dockerfile

This file was deleted.

27 changes: 5 additions & 22 deletions spring-petclinic-tracing-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<version>1.5.9</version>
</parent>

<properties>
<docker.image.exposed.port>8081</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
<!-- Spring Boot -->
<dependency>
Expand Down Expand Up @@ -63,28 +68,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
10 changes: 0 additions & 10 deletions spring-petclinic-tracing-server/src/main/docker/Dockerfile

This file was deleted.

27 changes: 5 additions & 22 deletions spring-petclinic-vets-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<version>1.5.9</version>
</parent>

<properties>
<docker.image.exposed.port>8081</docker.image.exposed.port>
<docker.image.dockerfile.dir>${basedir}/../docker</docker.image.dockerfile.dir>
</properties>

<dependencies>
<!-- Spring Boot -->
<dependency>
Expand Down Expand Up @@ -101,28 +106,6 @@
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker.plugin.version}</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<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}.jar</include>
</resource>
</resources>
<buildArgs>
<ARTIFACT_NAME>${project.build.finalName}</ARTIFACT_NAME>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Loading

0 comments on commit cf84ed0

Please sign in to comment.