A simple Spring Boot App to highlight how to dockerize it using Maven plugin and push it to Docker Hub.
- Clone this repository or create a new Spring Boot App
- If you have no Docker ID in Docker Hub, create one
- Open the
pom.xml
file and in the plugins section, add the following pluging:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.3</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>wilkom2009/docker-mvn-pub</repository>
<tag>${project.version}</tag>
</configuration>
</plugin>
- In the
<configuration>...</configuration>
section, changewilkom2009
to your Docker ID anddocker-mvn-pub
to the project Artifact Id - Create a
Dockerfile
in the project root and put below code:
FROM openjdk:8
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
PS : Here we use Open JDK 8
- Run Maven clean and package commands then push dokerfile :
mvn clean package dockerfile:push