-
Notifications
You must be signed in to change notification settings - Fork 566
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
65 changed files
with
3,804 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
target/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Copyright (c) 2021 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. | ||
# | ||
|
||
# 1st stage, build the app | ||
FROM maven:3.6-jdk-11 as build | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip | ||
|
||
# Do the Maven build! | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn package -DskipTests | ||
RUN echo "done!" | ||
|
||
# 2nd stage, build the runtime image | ||
FROM openjdk:11-jre-slim | ||
WORKDIR /helidon | ||
|
||
# Copy the binary built in the 1st stage | ||
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp.jar ./ | ||
COPY --from=build /helidon/target/libs ./libs | ||
|
||
CMD ["java", "-jar", "helidon-examples-integration-neo4j-mp.jar"] | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# Copyright (c) 2021 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. | ||
# | ||
|
||
# 1st stage, build the app | ||
FROM maven:3.6.3-jdk-11-slim as build | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip | ||
|
||
# Do the Maven build to create the custom Java Runtime Image | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn -Ddocker.build=true package -Pjlink-image -DskipTests | ||
RUN echo "done!" | ||
|
||
# 2nd stage, build the final image with the JRI built in the 1st stage | ||
|
||
FROM debian:stretch-slim | ||
WORKDIR /helidon | ||
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp-jri ./ | ||
ENTRYPOINT ["/bin/bash", "/helidon/bin/start"] | ||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# | ||
# Copyright (c) 2021 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. | ||
# | ||
|
||
# 1st stage, build the app | ||
FROM helidon/jdk11-graalvm-maven:20.2.0 as build | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
# Incremental docker builds will always resume after that, unless you update | ||
# the pom | ||
ADD pom.xml . | ||
RUN mvn package -Pnative-image -Dnative.image.skip -Dmaven.test.skip -Declipselink.weave.skip | ||
|
||
# Do the Maven build! | ||
# Incremental docker builds will resume here when you change sources | ||
ADD src src | ||
RUN mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests | ||
|
||
RUN echo "done!" | ||
|
||
# 2nd stage, build the runtime image | ||
FROM scratch | ||
WORKDIR /helidon | ||
|
||
# Copy the binary built in the 1st stage | ||
COPY --from=build /helidon/target/helidon-examples-integration-neo4j-mp . | ||
|
||
ENTRYPOINT ["./helidon-examples-integration-neo4j-mp"] | ||
|
||
EXPOSE 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Helidon Quickstart MP Example | ||
|
||
This example implements a simple Neo4j REST service using MicroProfile. | ||
|
||
## Build and run | ||
|
||
Bring up a Neo4j instance via Docker | ||
|
||
```bash | ||
docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:4.0 | ||
``` | ||
|
||
Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies). | ||
|
||
|
||
Then build with JDK11+ | ||
```bash | ||
mvn package | ||
java -jar target/helidon-integrations-neo4j-mp.jar | ||
``` | ||
|
||
## Exercise the application | ||
|
||
``` | ||
curl -X GET http://localhost:8080/movies | ||
``` | ||
|
||
## 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 helidon-integrations-neo4j-mp . | ||
``` | ||
|
||
## Start the application with Docker | ||
|
||
``` | ||
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp: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 helidon-integrations-neo4j-mp # 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. We recommend | ||
version `20.1.0` or later. | ||
|
||
``` | ||
# 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/helidon-quickstart-mp | ||
``` | ||
|
||
### Multi-stage Docker build | ||
|
||
Build the "native" Docker Image | ||
|
||
``` | ||
docker build -t helidon-integrations-neo4j-mp-native -f Dockerfile.native . | ||
``` | ||
|
||
Start the application: | ||
|
||
``` | ||
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-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/helidon-integrations-neo4j-mp-jri/bin/start | ||
``` | ||
|
||
### Multi-stage Docker build | ||
|
||
Build the JRI as a Docker Image | ||
|
||
``` | ||
docker build -t helidon-integrations-neo4j-mp-jri -f Dockerfile.jlink . | ||
``` | ||
|
||
Start the application: | ||
|
||
``` | ||
docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-jri:latest | ||
``` | ||
|
||
See the start script help: | ||
|
||
``` | ||
docker run --rm helidon-integrations-neo4j-mp-jri:latest --help | ||
``` |
Oops, something went wrong.