Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quickstart archetypes for SE and MP #2035

Merged
merged 2 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions archetypes/catalog/catalog.xml.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@
summary="Minimal Helidon MP application"
description="Minimal Helidon MP project suitable to start from scratch"
tags="mp,rest" />
<archetype artifactId="helidon-quickstart-se"
name="quickstart"
title="Helidon SE Quickstart"
summary="Sample Helidon SE application"
description="Sample Helidon SE project that includes multiple REST operations"
tags="se,rest" />
<archetype artifactId="helidon-quickstart-mp"
name="quickstart"
title="Helidon MP Quickstart"
summary="Sample Helidon MP application"
description="Sample Helidon MP project that includes multiple REST operations"
tags="se,rest" />
<archetype artifactId="helidon-database-mp"
name="database"
title="Helidon MP Database"
Expand Down
2 changes: 2 additions & 0 deletions archetypes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<modules>
<module>bare-se</module>
<module>bare-mp</module>
<module>quickstart-se</module>
<module>quickstart-mp</module>
<module>database-mp</module>
<module>database-se</module>
<module>catalog</module>
Expand Down
31 changes: 31 additions & 0 deletions archetypes/quickstart-mp/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2020 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<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>
<parent>
<groupId>io.helidon.archetypes</groupId>
<artifactId>helidon-archetypes-project</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<packaging>helidon-archetype</packaging>
<artifactId>helidon-quickstart-mp</artifactId>
<name>Helidon MP Quickstart Archetype</name>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2020 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->
<archetype-descriptor modelVersion="1.0" name="helidon-quickstart-mp">
<properties>
<property id="groupId" />
<property id="artifactId" />
<property id="version" value="1.0-SNAPSHOT" />
<property id="name" value="myproject" />
<property id="package" />
<property id="gradle" exported="false" />
<property id="maven" exported="false" />
<property id="helidonVersion" exported="false" readonly="true" value="{{project.version}}"/>
</properties>
<transformations>
<transformation id="packaged">
<replace regex="__pkg__" replacement="${package/\./\/}"/>
</transformation>
<transformation id="mustache">
<replace regex="\.mustache$" replacement=""/>
</transformation>
</transformations>
<template-sets transformations="mustache">
<template-set transformations="packaged">
<directory>src/main/java</directory>
<includes>
<include>**/*.mustache</include>
</includes>
</template-set>
<template-set transformations="packaged">
<directory>src/test/java</directory>
<includes>
<include>**/*.mustache</include>
</includes>
</template-set>
<template-set if="gradle">
<directory>.</directory>
<includes>
<include>build.gradle.mustache</include>
<include>README.md.mustache</include>
</includes>
</template-set>
<template-set if="maven">
<directory>.</directory>
<includes>
<include>pom.xml.mustache</include>
<include>README.md.mustache</include>
</includes>
</template-set>
</template-sets>
<file-sets>
<file-set transformations="packaged">
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.mustache</exclude>
</excludes>
</file-set>
<file-set>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
</file-set>
<file-set transformations="packaged">
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.mustache</exclude>
</excludes>
</file-set>
<file-set>
<directory>src/test/resources</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</file-set>
</file-sets>
<input-flow>
<input property="name" text="Project name" default="${name}"/>
<input property="groupId" text="Project groupId" if="maven" default="${groupId}"/>
<input property="artifactId" text="Project artifactId" default="${artifactId}"/>
<input property="version" text="Project version" default="${version}"/>
<input property="package" text="Java package name" default="${package}"/>
</input-flow>
</archetype-descriptor>
166 changes: 166 additions & 0 deletions archetypes/quickstart-mp/src/main/resources/README.md.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# Helidon Quickstart MP

This example implements a simple Hello World REST service using MicroProfile.

## Build and run

With JDK11+
```bash
mvn package
java -jar target/{{artifactId}}.jar
```

## Exercise the application

```
curl -X GET http://localhost:8080/greet
{"message":"Hello World!"}

curl -X GET http://localhost:8080/greet/Joe
{"message":"Hello Joe!"}

curl -X PUT -H "Content-Type: application/json" -d '{"greeting" : "Hola"}' http://localhost:8080/greet/greeting

curl -X GET http://localhost:8080/greet/Jose
{"message":"Hola Jose!"}
```

## Try health and metrics

```
curl -s -X GET http://localhost:8080/health
{"outcome":"UP",...
. . .

# Prometheus Format
curl -s -X GET http://localhost:8080/metrics
# TYPE base:gc_g1_young_generation_count gauge
. . .

# JSON Format
curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics
{"base":...
. . .

```

## Build the Docker Image

```
docker build -t {{artifactId}} .
```

## Start the application with Docker

```
docker run --rm -p 8080:8080 {{artifactId}}:latest
```

Exercise the application as described above

## Deploy the application to Kubernetes

```
kubectl cluster-info # Verify which cluster
kubectl get pods # Verify connectivity to cluster
kubectl create -f app.yaml # Deploy application
kubectl get service {{artifactId}} # Verify deployed service
```

## Build a native image with GraalVM

GraalVM allows you to compile your programs ahead-of-time into a native
executable. See https://www.graalvm.org/docs/reference-manual/aot-compilation/
for more information.

You can build a native executable in 2 different ways:
* With a local installation of GraalVM
* Using Docker

### Local build

Download Graal VM at https://www.graalvm.org/downloads, the version
currently supported for Helidon is `20.0`.

```
# Setup the environment
export GRAALVM_HOME=/path
# build the native executable
mvn package -Pnative-image
```

You can also put the Graal VM `bin` directory in your PATH, or pass
`-DgraalVMHome=/path` to the Maven command.

See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-native-image
for more information.

Start the application:

```
./target/{{artifactId}}
```

### Multi-stage Docker build

Build the "native" Docker Image

```
docker build -t {{artifactId}}-native -f Dockerfile.native .
```

Start the application:

```
docker run --rm -p 8080:8080 {{artifactId}}-native:latest
```


## Build a Java Runtime Image using jlink

You can build a custom Java Runtime Image (JRI) containing the application jars and the JDK modules
on which they depend. This image also:

* Enables Class Data Sharing by default to reduce startup time.
* Contains a customized `start` script to simplify CDS usage and support debug and test modes.

You can build a custom JRI in two different ways:
* Local
* Using Docker


### Local build

```
# build the JRI
mvn package -Pjlink-image
```

See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-jlink-image
for more information.

Start the application:

```
./target/{{artifactId}}/bin/start
```

### Multi-stage Docker build

Build the "jlink" Docker Image

```
docker build -t {{artifactId}}-jlink -f Dockerfile.jlink .
```

Start the application:

```
docker run --rm -p 8080:8080 {{artifactId}}-jlink:latest
```

See the start script help:

```
docker run --rm {{artifactId}}-jlink:latest --help
```
Loading