BAEL-2877 Quarkus IO
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
####
|
||||
# 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/quarkus-project-jvm .
|
||||
#
|
||||
# Then run the container using:
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 quarkus/quarkus-project-jvm
|
||||
#
|
||||
###
|
||||
FROM fabric8/java-jboss-openjdk8-jdk
|
||||
ENV JAVA_OPTIONS=-Dquarkus.http.host=0.0.0.0
|
||||
COPY target/lib/* /deployments/lib/
|
||||
COPY target/*-runner.jar /deployments/app.jar
|
||||
ENTRYPOINT [ "/deployments/run-java.sh" ]
|
||||
@@ -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 -Dnative-image.docker-build=true
|
||||
#
|
||||
# Then, build the image with:
|
||||
#
|
||||
# docker build -f src/main/docker/Dockerfile.native -t quarkus/quarkus-project .
|
||||
#
|
||||
# Then run the container using:
|
||||
#
|
||||
# docker run -i --rm -p 8080:8080 quarkus/quarkus-project
|
||||
#
|
||||
###
|
||||
FROM registry.fedoraproject.org/fedora-minimal
|
||||
WORKDIR /work/
|
||||
COPY target/*-runner /work/application
|
||||
RUN chmod 775 /work
|
||||
EXPOSE 8080
|
||||
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.quarkus;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
@Path("/hello")
|
||||
public class HelloResource {
|
||||
|
||||
@Inject
|
||||
HelloService helloService;
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/polite/{name}")
|
||||
public String greeting(@PathParam("name") String name) {
|
||||
return helloService.politeHello(name);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String hello() {
|
||||
return "hello";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.quarkus;
|
||||
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty;
|
||||
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
|
||||
@ApplicationScoped
|
||||
public class HelloService {
|
||||
|
||||
@ConfigProperty(name = "greeting")
|
||||
private String greeting;
|
||||
|
||||
public String politeHello(String name){
|
||||
return greeting + " " + name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>quarkus-project - 1.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: com.baeldung.quarkus</li>
|
||||
<li>ArtifactId: quarkus-project</li>
|
||||
<li>Version: 1.0-SNAPSHOT</li>
|
||||
<li>Quarkus Version: 0.13.1</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="right-section">
|
||||
<h3>Next steps</h3>
|
||||
<ul>
|
||||
<li><a href="https://quarkus.io/guides/maven-tooling.html">Setup your IDE</a></li>
|
||||
<li><a href="https://quarkus.io/guides/getting-started-guide.html">Getting started</a></li>
|
||||
<li><a href="https://quarkus.io">Quarkus Web Site</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
# Configuration file
|
||||
# key = value
|
||||
greeting=Good morning
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.quarkus;
|
||||
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static io.restassured.RestAssured.given;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
@QuarkusTest
|
||||
public class HelloResourceTest {
|
||||
|
||||
@Test
|
||||
public void testHelloEndpoint() {
|
||||
given()
|
||||
.when().get("/hello")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body(is("hello"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.quarkus;
|
||||
|
||||
import io.quarkus.test.junit.SubstrateTest;
|
||||
|
||||
@SubstrateTest
|
||||
public class NativeHelloResourceIT extends HelloResourceTest {
|
||||
|
||||
// Execute the same tests but in native mode.
|
||||
}
|
||||
Reference in New Issue
Block a user