From 4c5847bffd0401e62a3f2beaeba8c0cb887359ce Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 12 Jan 2020 15:42:02 +0100 Subject: Import fresh Quarkus project. Change-Id: I05fa5dd499cdca04adee9afbef9f83b3afd8fe0f --- src/main/docker/Dockerfile.jvm | 34 +++++ src/main/docker/Dockerfile.native | 22 +++ src/main/resources/META-INF/resources/index.html | 152 +++++++++++++++++++++ src/main/resources/application.properties | 2 + src/main/scala/eu/mulk/ExampleResource.scala | 12 ++ .../scala/eu/mulk/NativeExampleResourceIT.scala | 6 + src/test/scala/eu/mulk/ExampleResourceTest.scala | 21 +++ 7 files changed, 249 insertions(+) create mode 100644 src/main/docker/Dockerfile.jvm create mode 100644 src/main/docker/Dockerfile.native create mode 100644 src/main/resources/META-INF/resources/index.html create mode 100644 src/main/resources/application.properties create mode 100644 src/main/scala/eu/mulk/ExampleResource.scala create mode 100644 src/native-test/scala/eu/mulk/NativeExampleResourceIT.scala create mode 100644 src/test/scala/eu/mulk/ExampleResourceTest.scala (limited to 'src') diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..c7ff48c --- /dev/null +++ b/src/main/docker/Dockerfile.jvm @@ -0,0 +1,34 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the docker image run: +# +# mvn package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/mulkcms2-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/mulkcms2-jvm +# +### +FROM fabric8/java-alpine-openjdk8-jre:1.6.5 +ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV AB_ENABLED=jmx_exporter + +# Be prepared for running in OpenShift too +RUN adduser -G root --no-create-home --disabled-password 1001 \ + && chown -R 1001 /deployments \ + && chmod -R "g+rwX" /deployments \ + && chown -R 1001:root /deployments + +COPY build/lib/* /deployments/lib/ +COPY build/*-runner.jar /deployments/app.jar +EXPOSE 8080 + +# run with user 1001 +USER 1001 + +ENTRYPOINT [ "/deployments/run-java.sh" ] \ No newline at end of file diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..1cb12dd --- /dev/null +++ b/src/main/docker/Dockerfile.native @@ -0,0 +1,22 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode +# +# Before building the docker image run: +# +# mvn package -Pnative -Dquarkus.native.container-build=true +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/mulkcms2 . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/mulkcms2 +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal +WORKDIR /work/ +COPY build/*-runner /work/application +RUN chmod 775 /work +EXPOSE 8080 +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/index.html b/src/main/resources/META-INF/resources/index.html new file mode 100644 index 0000000..cf4f91b --- /dev/null +++ b/src/main/resources/META-INF/resources/index.html @@ -0,0 +1,152 @@ + + + + + mulkcms2 - 1.0.0-SNAPSHOT + + + + + + +
+
+

Congratulations, you have created a new Quarkus application.

+ +

Why do you see this?

+ +

This page is served by Quarkus. The source is in + src/main/resources/META-INF/resources/index.html.

+ +

What can I do from here?

+ +

If not already done, run the application in dev mode using: mvn compile quarkus:dev. +

+
    +
  • Add REST resources, Servlets, functions and other services in src/main/java.
  • +
  • Your static assets are located in src/main/resources/META-INF/resources.
  • +
  • Configure your application in src/main/resources/application.properties. +
  • +
+ +

How do I get rid of this page?

+

Just delete the src/main/resources/META-INF/resources/index.html file.

+
+
+
+

Application

+
    +
  • GroupId: eu.mulk
  • +
  • ArtifactId: mulkcms2
  • +
  • Version: 1.0.0-SNAPSHOT
  • +
  • Quarkus Version: 1.1.1.Final
  • +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..3c1ac56 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,2 @@ +# Configuration file +# key = value \ No newline at end of file diff --git a/src/main/scala/eu/mulk/ExampleResource.scala b/src/main/scala/eu/mulk/ExampleResource.scala new file mode 100644 index 0000000..a68b2a7 --- /dev/null +++ b/src/main/scala/eu/mulk/ExampleResource.scala @@ -0,0 +1,12 @@ +package eu.mulk + +import javax.ws.rs.{GET, Path, Produces} +import javax.ws.rs.core.MediaType + +@Path("/hello") +class ExampleResource { + + @GET + @Produces(Array[String](MediaType.TEXT_PLAIN)) + def hello() = "hello!" +} diff --git a/src/native-test/scala/eu/mulk/NativeExampleResourceIT.scala b/src/native-test/scala/eu/mulk/NativeExampleResourceIT.scala new file mode 100644 index 0000000..f4a3e01 --- /dev/null +++ b/src/native-test/scala/eu/mulk/NativeExampleResourceIT.scala @@ -0,0 +1,6 @@ +package eu.mulk + +import io.quarkus.test.junit.NativeImageTest + +@NativeImageTest +class NativeExampleResourceIT extends ExampleResourceTest diff --git a/src/test/scala/eu/mulk/ExampleResourceTest.scala b/src/test/scala/eu/mulk/ExampleResourceTest.scala new file mode 100644 index 0000000..41f96bb --- /dev/null +++ b/src/test/scala/eu/mulk/ExampleResourceTest.scala @@ -0,0 +1,21 @@ +package eu.mulk + +import io.quarkus.test.junit.QuarkusTest +import io.restassured.RestAssured.given +import org.hamcrest.CoreMatchers.`is` +import org.junit.jupiter.api.Test + +@QuarkusTest +class ExampleResourceTest { + + @Test + def testHelloEndpoint() = { + given() + .`when`() + .get("/hello") + .`then`() + .statusCode(200) + .body(`is`("hello")) + } + +} -- cgit v1.2.3