Last active
July 24, 2016 16:02
-
-
Save carlosjgp/ce6469f1ef71157c4deec21882186281 to your computer and use it in GitHub Desktop.
[Spring Boot] Docker compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -P com.example/demo && docker ps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -p 8080:8080 com.example/demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM anapsix/alpine-java | |
EXPOSE 8080 | |
ADD target.jar app.jar | |
RUN sh -c 'touch /app.jar' | |
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
<properties> | |
... | |
<!-- Docker properties --> | |
<docker.plugin.version>0.4.10</docker.plugin.version> | |
<docker.image.prefix>${project.groupId}</docker.image.prefix> | |
<docker.image.name>${docker.image.prefix}/${project.artifactId}</docker.image.name> | |
... | |
</properties> | |
... | |
<build> | |
<plugins> | |
... | |
<plugin> | |
<groupId>com.spotify</groupId> | |
<artifactId>docker-maven-plugin</artifactId> | |
<version>${docker.plugin.version}</version> | |
<configuration> | |
<imageName>${docker.image.name}</imageName> | |
<dockerDirectory>docker</dockerDirectory> | |
<resources> | |
<resource> | |
<targetPath>/</targetPath> | |
<directory>${project.build.directory}</directory> | |
<include>${project.build.finalName}.jar</include> | |
</resource> | |
</resources> | |
</configuration> | |
<executions> | |
<execution> | |
<id>build-image</id> | |
<phase>package</phase> | |
<goals> | |
<goal>build</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>tag-image</id> | |
<phase>package</phase> | |
<goals> | |
<goal>tag</goal> | |
</goals> | |
<configuration> | |
<image>${docker.image.name}</image> | |
<newName>${docker.image.name}:${project.version}</newName> | |
</configuration> | |
</execution> | |
<execution> | |
<id>push-image</id> | |
<phase>deploy</phase> | |
<goals> | |
<goal>push</goal> | |
</goals> | |
<configuration> | |
<imageName>${docker.image.prefix}/${project.artifactId}:${project.version}</imageName> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
... | |
</plugins> | |
... | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mvn clean package && docker run -p 8080:8080 com.example/demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
... | |
<build> | |
<!-- Generic name for all the JARs --> | |
<finalName>target</finalName> | |
... | |
</build> | |
... | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment