From 49463cdfdf85856456b08c64bee35742bcf78d0d Mon Sep 17 00:00:00 2001 From: Anca Iordache Date: Thu, 5 Mar 2020 19:07:18 +0100 Subject: [PATCH] add sparkjava application sample Signed-off-by: Anca Iordache --- samples/sparkjava/docker-compose.yaml | 6 +++ samples/sparkjava/sparkjava/Dockerfile | 10 ++++ samples/sparkjava/sparkjava/pom.xml | 48 +++++++++++++++++++ .../sparkjava/src/main/java/App.java | 9 ++++ 4 files changed, 73 insertions(+) create mode 100644 samples/sparkjava/docker-compose.yaml create mode 100755 samples/sparkjava/sparkjava/Dockerfile create mode 100755 samples/sparkjava/sparkjava/pom.xml create mode 100755 samples/sparkjava/sparkjava/src/main/java/App.java diff --git a/samples/sparkjava/docker-compose.yaml b/samples/sparkjava/docker-compose.yaml new file mode 100644 index 0000000..9a8d2bf --- /dev/null +++ b/samples/sparkjava/docker-compose.yaml @@ -0,0 +1,6 @@ +version: "3.7" +services: + sparkjava: + build: sparkjava + ports: + - 80:8080 diff --git a/samples/sparkjava/sparkjava/Dockerfile b/samples/sparkjava/sparkjava/Dockerfile new file mode 100755 index 0000000..4df8594 --- /dev/null +++ b/samples/sparkjava/sparkjava/Dockerfile @@ -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 diff --git a/samples/sparkjava/sparkjava/pom.xml b/samples/sparkjava/sparkjava/pom.xml new file mode 100755 index 0000000..e2f41ea --- /dev/null +++ b/samples/sparkjava/sparkjava/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + com.company + project + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + + + + maven-assembly-plugin + + + + App + + + + jar-with-dependencies + + app + false + + + + + + + + com.sparkjava + spark-core + 2.5 + + + + + \ No newline at end of file diff --git a/samples/sparkjava/sparkjava/src/main/java/App.java b/samples/sparkjava/sparkjava/src/main/java/App.java new file mode 100755 index 0000000..d3b0d80 --- /dev/null +++ b/samples/sparkjava/sparkjava/src/main/java/App.java @@ -0,0 +1,9 @@ +import static spark.Spark.*; + +public class App { + public static void main(String[] args) { + port(8080); + + get("/", (req, res) -> "Hello world"); + } +}