diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/docker/Dockerfile.jvm | 34 | ||||
-rw-r--r-- | src/main/docker/Dockerfile.native | 22 | ||||
-rw-r--r-- | src/main/resources/META-INF/resources/index.html | 152 | ||||
-rw-r--r-- | src/main/resources/application.properties | 2 | ||||
-rw-r--r-- | src/main/scala/eu/mulk/ExampleResource.scala | 12 | ||||
-rw-r--r-- | src/native-test/scala/eu/mulk/NativeExampleResourceIT.scala | 6 | ||||
-rw-r--r-- | src/test/scala/eu/mulk/ExampleResourceTest.scala | 21 |
7 files changed, 249 insertions, 0 deletions
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 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>mulkcms2 - 1.0.0-SNAPSHOT</title> + <style> + h1, h2, h3, h4, h5, h6 { + margin-bottom: 0.5rem; + font-weight: 400; + line-height: 1.5; + } + + h1 { + font-size: 2.5rem; + } + + h2 { + font-size: 2rem + } + + h3 { + font-size: 1.75rem + } + + h4 { + font-size: 1.5rem + } + + h5 { + font-size: 1.25rem + } + + h6 { + font-size: 1rem + } + + .lead { + font-weight: 300; + font-size: 2rem; + } + + .banner { + font-size: 2.7rem; + margin: 0; + padding: 2rem 1rem; + background-color: #00A1E2; + color: white; + } + + body { + margin: 0; + font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; + } + + code { + font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-size: 87.5%; + color: #e83e8c; + word-break: break-word; + } + + .left-column { + padding: .75rem; + max-width: 75%; + min-width: 55%; + } + + .right-column { + padding: .75rem; + max-width: 25%; + } + + .container { + display: flex; + width: 100%; + } + + li { + margin: 0.75rem; + } + + .right-section { + margin-left: 1rem; + padding-left: 0.5rem; + } + + .right-section h3 { + padding-top: 0; + font-weight: 200; + } + + .right-section ul { + border-left: 0.3rem solid #00A1E2; + list-style-type: none; + padding-left: 0; + } + + </style> +</head> +<body> + +<div class="banner lead"> + Your new Cloud-Native application is ready! +</div> + +<div class="container"> + <div class="left-column"> + <p class="lead"> Congratulations, you have created a new Quarkus application.</p> + + <h2>Why do you see this?</h2> + + <p>This page is served by Quarkus. The source is in + <code>src/main/resources/META-INF/resources/index.html</code>.</p> + + <h2>What can I do from here?</h2> + + <p>If not already done, run the application in <em>dev mode</em> using: <code>mvn compile quarkus:dev</code>. + </p> + <ul> + <li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li> + <li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li> + <li>Configure your application in <code>src/main/resources/application.properties</code>. + </li> + </ul> + + <h2>How do I get rid of this page?</h2> + <p>Just delete the <code>src/main/resources/META-INF/resources/index.html</code> file.</p> + </div> + <div class="right-column"> + <div class="right-section"> + <h3>Application</h3> + <ul> + <li>GroupId: eu.mulk</li> + <li>ArtifactId: mulkcms2</li> + <li>Version: 1.0.0-SNAPSHOT</li> + <li>Quarkus Version: 1.1.1.Final</li> + </ul> + </div> + <div class="right-section"> + <h3>Next steps</h3> + <ul> + <li><a href="https://quarkus.io/guides/maven-tooling.html" target="_blank">Setup your IDE</a></li> + <li><a href="https://quarkus.io/guides/getting-started.html" target="_blank">Getting started</a></li> + <li><a href="https://quarkus.io" target="_blank">Quarkus Web Site</a></li> + </ul> + </div> + </div> +</div> + + +</body> +</html>
\ 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")) + } + +} |