The application can be started as a container via Docker Compose
authorKai Moritz <kai@juplo.de>
Sun, 25 Oct 2020 15:31:03 +0000 (16:31 +0100)
committerKai Moritz <kai@juplo.de>
Sat, 6 Feb 2021 15:41:21 +0000 (16:41 +0100)
* Added docker-maven-plugin to build an image of the application
* Added a setup for Docker Compose, that starts the image as container

.dockerignore [new file with mode: 0644]
Dockerfile [new file with mode: 0644]
docker-compose.yml [new file with mode: 0644]
pom.xml

diff --git a/.dockerignore b/.dockerignore
new file mode 100644 (file)
index 0000000..1ad9963
--- /dev/null
@@ -0,0 +1,2 @@
+*
+!target/*.jar
diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..89e2ebb
--- /dev/null
@@ -0,0 +1,5 @@
+FROM openjdk:8-jre-alpine
+VOLUME /tmp
+COPY target/*.jar /opt/app.jar
+ENTRYPOINT [ "/usr/bin/java", "-jar", "/opt/app.jar" ]
+CMD []
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644 (file)
index 0000000..79f5d1c
--- /dev/null
@@ -0,0 +1,7 @@
+version: "3"
+
+services:
+  jdbc:
+    image: jdbc:latest
+    ports:
+      - 8080:8080
diff --git a/pom.xml b/pom.xml
index 4cc7dc3..82dc5dd 100644 (file)
--- a/pom.xml
+++ b/pom.xml
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
+       <plugin>
+         <groupId>io.fabric8</groupId>
+         <artifactId>docker-maven-plugin</artifactId>
+         <version>0.33.0</version>
+         <configuration>
+           <images>
+             <image>
+               <name>%a:%l</name>
+             </image>
+           </images>
+         </configuration>
+         <executions>
+           <execution>
+              <id>build</id>
+              <phase>package</phase>
+              <goals>
+                <goal>build</goal>
+              </goals>
+           </execution>
+         </executions>
+       </plugin>
      </plugins>
    </build>