|
| 1 | +# Helidon Quickstart MP Example |
| 2 | + |
| 3 | +This example implements a simple Neo4j REST service using MicroProfile. |
| 4 | + |
| 5 | +## Build and run |
| 6 | + |
| 7 | +Bring up a Neo4j instance via Docker |
| 8 | + |
| 9 | +```bash |
| 10 | +docker run --publish=7474:7474 --publish=7687:7687 -e 'NEO4J_AUTH=neo4j/secret' neo4j:4.0 |
| 11 | +``` |
| 12 | + |
| 13 | +Goto the Neo4j browser and play the first step of the movies graph: [`:play movies`](http://localhost:7474/browser/?cmd=play&arg=movies). |
| 14 | + |
| 15 | + |
| 16 | +Then build with JDK11+ |
| 17 | +```bash |
| 18 | +mvn package |
| 19 | +java -jar target/helidon-integrations-neo4j-mp.jar |
| 20 | +``` |
| 21 | + |
| 22 | +## Exercise the application |
| 23 | + |
| 24 | +``` |
| 25 | +curl -X GET http://localhost:8080/movies |
| 26 | +
|
| 27 | +``` |
| 28 | + |
| 29 | +## Try health and metrics |
| 30 | + |
| 31 | +``` |
| 32 | +curl -s -X GET http://localhost:8080/health |
| 33 | +{"outcome":"UP",... |
| 34 | +. . . |
| 35 | +
|
| 36 | +# Prometheus Format |
| 37 | +curl -s -X GET http://localhost:8080/metrics |
| 38 | +# TYPE base:gc_g1_young_generation_count gauge |
| 39 | +. . . |
| 40 | +
|
| 41 | +# JSON Format |
| 42 | +curl -H 'Accept: application/json' -X GET http://localhost:8080/metrics |
| 43 | +{"base":... |
| 44 | +. . . |
| 45 | +
|
| 46 | +``` |
| 47 | + |
| 48 | +## Build the Docker Image |
| 49 | + |
| 50 | +``` |
| 51 | +docker build -t helidon-integrations-neo4j-mp . |
| 52 | +``` |
| 53 | + |
| 54 | +## Start the application with Docker |
| 55 | + |
| 56 | +``` |
| 57 | +docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp:latest |
| 58 | +``` |
| 59 | + |
| 60 | +Exercise the application as described above |
| 61 | + |
| 62 | +## Deploy the application to Kubernetes |
| 63 | + |
| 64 | +``` |
| 65 | +kubectl cluster-info # Verify which cluster |
| 66 | +kubectl get pods # Verify connectivity to cluster |
| 67 | +kubectl create -f app.yaml # Deploy application |
| 68 | +kubectl get service helidon-integrations-neo4j-mp # Verify deployed service |
| 69 | +``` |
| 70 | + |
| 71 | +## Build a native image with GraalVM |
| 72 | + |
| 73 | +GraalVM allows you to compile your programs ahead-of-time into a native |
| 74 | + executable. See https://www.graalvm.org/docs/reference-manual/aot-compilation/ |
| 75 | + for more information. |
| 76 | + |
| 77 | +You can build a native executable in 2 different ways: |
| 78 | +* With a local installation of GraalVM |
| 79 | +* Using Docker |
| 80 | + |
| 81 | +### Local build |
| 82 | + |
| 83 | +Download Graal VM at https://www.graalvm.org/downloads. We recommend |
| 84 | +version `20.1.0` or later. |
| 85 | + |
| 86 | +``` |
| 87 | +# Setup the environment |
| 88 | +export GRAALVM_HOME=/path |
| 89 | +# build the native executable |
| 90 | +mvn package -Pnative-image |
| 91 | +``` |
| 92 | + |
| 93 | +You can also put the Graal VM `bin` directory in your PATH, or pass |
| 94 | + `-DgraalVMHome=/path` to the Maven command. |
| 95 | + |
| 96 | +See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-native-image |
| 97 | + for more information. |
| 98 | + |
| 99 | +Start the application: |
| 100 | + |
| 101 | +``` |
| 102 | +./target/helidon-quickstart-mp |
| 103 | +``` |
| 104 | + |
| 105 | +### Multi-stage Docker build |
| 106 | + |
| 107 | +Build the "native" Docker Image |
| 108 | + |
| 109 | +``` |
| 110 | +docker build -t helidon-integrations-neo4j-mp-native -f Dockerfile.native . |
| 111 | +``` |
| 112 | + |
| 113 | +Start the application: |
| 114 | + |
| 115 | +``` |
| 116 | +docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-native:latest |
| 117 | +``` |
| 118 | + |
| 119 | + |
| 120 | +## Build a Java Runtime Image using jlink |
| 121 | + |
| 122 | +You can build a custom Java Runtime Image (JRI) containing the application jars and the JDK modules |
| 123 | +on which they depend. This image also: |
| 124 | + |
| 125 | +* Enables Class Data Sharing by default to reduce startup time. |
| 126 | +* Contains a customized `start` script to simplify CDS usage and support debug and test modes. |
| 127 | + |
| 128 | +You can build a custom JRI in two different ways: |
| 129 | +* Local |
| 130 | +* Using Docker |
| 131 | + |
| 132 | + |
| 133 | +### Local build |
| 134 | + |
| 135 | +``` |
| 136 | +# build the JRI |
| 137 | +mvn package -Pjlink-image |
| 138 | +``` |
| 139 | + |
| 140 | +See https://github.com/oracle/helidon-build-tools/tree/master/helidon-maven-plugin#goal-jlink-image |
| 141 | + for more information. |
| 142 | + |
| 143 | +Start the application: |
| 144 | + |
| 145 | +``` |
| 146 | +./target/helidon-integrations-neo4j-mp-jri/bin/start |
| 147 | +``` |
| 148 | + |
| 149 | +### Multi-stage Docker build |
| 150 | + |
| 151 | +Build the JRI as a Docker Image |
| 152 | + |
| 153 | +``` |
| 154 | +docker build -t helidon-integrations-neo4j-mp-jri -f Dockerfile.jlink . |
| 155 | +``` |
| 156 | + |
| 157 | +Start the application: |
| 158 | + |
| 159 | +``` |
| 160 | +docker run --rm -p 8080:8080 helidon-integrations-neo4j-mp-jri:latest |
| 161 | +``` |
| 162 | + |
| 163 | +See the start script help: |
| 164 | + |
| 165 | +``` |
| 166 | +docker run --rm helidon-integrations-neo4j-mp-jri:latest --help |
| 167 | +``` |
0 commit comments