add sparkjava application sample
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
This commit is contained in:
parent
3a23aa59d2
commit
49463cdfdf
6
samples/sparkjava/docker-compose.yaml
Normal file
6
samples/sparkjava/docker-compose.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
version: "3.7"
|
||||
services:
|
||||
sparkjava:
|
||||
build: sparkjava
|
||||
ports:
|
||||
- 80:8080
|
10
samples/sparkjava/sparkjava/Dockerfile
Executable file
10
samples/sparkjava/sparkjava/Dockerfile
Executable file
@ -0,0 +1,10 @@
|
||||
FROM maven:3.5-jdk-8-alpine AS build
|
||||
COPY pom.xml .
|
||||
RUN mvn --batch-mode dependency:resolve
|
||||
COPY src/ src
|
||||
RUN mvn --batch-mode clean compile assembly:single
|
||||
|
||||
FROM openjdk:8-jre-alpine3.7
|
||||
EXPOSE 8080
|
||||
COPY --from=build target/app.jar /app.jar
|
||||
CMD java -jar /app.jar
|
48
samples/sparkjava/sparkjava/pom.xml
Executable file
48
samples/sparkjava/sparkjava/pom.xml
Executable file
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.company</groupId>
|
||||
<artifactId>project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>App</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
<finalName>app</finalName>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.sparkjava</groupId>
|
||||
<artifactId>spark-core</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
9
samples/sparkjava/sparkjava/src/main/java/App.java
Executable file
9
samples/sparkjava/sparkjava/src/main/java/App.java
Executable file
@ -0,0 +1,9 @@
|
||||
import static spark.Spark.*;
|
||||
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
port(8080);
|
||||
|
||||
get("/", (req, res) -> "Hello world");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user