-
Notifications
You must be signed in to change notification settings - Fork 93
Doc and sample updates for 1.4.0 #1076
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
Draft
markxnelson
wants to merge
17
commits into
main
Choose a base branch
from
mark/1.4.0
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c6328c5
starting point
markxnelson 2f44332
starting point
markxnelson 942d2c4
working on doc updates
markxnelson 0dcb6c2
enable hibernate to create tables
ddrechse c15e92b
Merge branch 'mark/1.4.0' of github.com:oracle/microservices-datadriv…
ddrechse d7c74ac
Clean up of file
ddrechse 03b0a84
Revert "Merge branch 'mark/1.4.0' of github.com:oracle/microservices-…
ddrechse 6387130
Enable Helidon Table Creation (#1078)
ddrechse 110b73e
Fix customer api (#1079)
ddrechse facd9f7
Merge branch 'main' into mark/1.4.0
markxnelson 65e3d62
Fix Microprofile image and add Eureka connection (#1082)
ddrechse 8b1e376
Support Liquibase (#1083)
ddrechse 2b06b38
Add OCA to gitignore
andytael faf6a9a
gitignore update to remove OCA stuff
andytael bc0d2d4
gitignore update
andytael 53e72b9
Docu update
andytael 31abf16
Duplicate dependency
andytael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -520,3 +520,7 @@ package* | |
# GraalVM stuff | ||
*.nib | ||
docs-source/**/public | ||
|
||
# OCA | ||
.oca/ | ||
.oca/* |
This file contains hidden or 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 hidden or 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,38 @@ | ||
# Compiled class file | ||
*.class | ||
|
||
# Maven | ||
target/ | ||
.m2/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
# IntelliJ Idea | ||
.idea/* | ||
!.idea/runConfigurations | ||
*.iws | ||
*.ipr | ||
*.iml | ||
*.releaseBackup | ||
atlassian-ide-plugin.xml | ||
|
||
# Netbeans | ||
nbactions.xml | ||
nb-configuration.xml | ||
|
||
# Eclipse | ||
.settings | ||
.settings/ | ||
.project | ||
.classpath | ||
.factorypath | ||
|
||
# OCA | ||
.oca/* |
This file contains hidden or 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,6 @@ | ||
#Helidon Project Configuration | ||
#Wed Jun 18 10:11:56 EDT 2025 | ||
schema.version=1.1.0 | ||
helidon.version=4.2.3 | ||
project.flavor=mp | ||
project.archetype=quickstart |
This file contains hidden or 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,35 @@ | ||
# 1st stage, build the app | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build | ||
|
||
# Install maven | ||
WORKDIR /usr/share | ||
RUN set -x && \ | ||
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ | ||
tar -xvf apache-maven-*-bin.tar.gz && \ | ||
rm apache-maven-*-bin.tar.gz && \ | ||
mv apache-maven-* maven && \ | ||
ln -s /usr/share/maven/bin/mvn /bin/ | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
ADD pom.xml . | ||
Check noticeCode scanning / SonarCloud Prefer COPY over ADD for copying local resources Low
Replace this ADD instruction with a COPY instruction. See more on SonarQube Cloud
|
||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip -DskipOpenApiGenerate | ||
|
||
# Do the Maven build with fat JAR! | ||
ADD src src | ||
|
||
RUN mvn package -DskipTests | ||
|
||
# 2nd stage, build the runtime image | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 | ||
|
||
WORKDIR /helidon | ||
|
||
# Copy ONLY the fat JAR (not libs directory) | ||
COPY --from=build /helidon/target/*.jar app.jar | ||
|
||
# Simple fat JAR execution | ||
CMD ["java", "-jar", "app.jar"] | ||
|
||
EXPOSE 8080 | ||
|
This file contains hidden or 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,216 @@ | ||
# customer-helidon | ||
|
||
Helidon MP version of the "customer" microservice built using the **Helidon MP profile** for enterprise Java applications with CDI, JPA, and microservices capabilities. | ||
|
||
## Build and run | ||
|
||
### Prerequisites | ||
- JDK 21 | ||
- Maven 3.8+ | ||
|
||
### Building the Application | ||
|
||
The build process creates a **thin JAR deployment package** as a ZIP file containing the application JAR and all dependencies: | ||
|
||
```bash | ||
mvn clean package | ||
``` | ||
|
||
This creates: | ||
- `target/customer-helidon.jar` - The thin application JAR | ||
- `target/customer-helidon-deployment.zip` - Complete deployment package with structure: | ||
``` | ||
customer-helidon.jar (main application) | ||
app/ | ||
libs/ (all dependency JARs) | ||
``` | ||
|
||
### Running the Application | ||
|
||
**Option 1: Using the thin JAR (requires dependencies in classpath):** | ||
```bash | ||
# Extract the deployment ZIP first | ||
cd target | ||
unzip customer-helidon-deployment.zip | ||
java -jar customer-helidon.jar | ||
``` | ||
|
||
**Option 2: Using Maven to run directly:** | ||
```bash | ||
mvn exec:java | ||
``` | ||
|
||
## Quick Start with Local Oracle Database | ||
|
||
To run against a local Oracle Docker container, simply: | ||
|
||
1. **Start Oracle Database container:** | ||
```bash | ||
docker run -d --name oracle-db -p 1521:1521 \ | ||
-e ORACLE_PWD=Welcome12345 \ | ||
container-registry.oracle.com/database/free:latest | ||
``` | ||
|
||
2. **Uncomment database configuration** in `src/main/resources/application.yaml`: | ||
```yaml | ||
javax.sql.DataSource.customer.URL = jdbc:oracle:thin:@//localhost:1521/freepdb1 | ||
javax.sql.DataSource.customer.user = customer | ||
javax.sql.DataSource.customer.password = Welcome12345 | ||
``` | ||
|
||
3. **Rebuild and run:** | ||
```bash | ||
mvn clean package | ||
cd target && unzip customer-helidon-deployment.zip | ||
java -jar customer-helidon.jar | ||
``` | ||
|
||
The application will automatically create the necessary database tables on startup using Hibernate's DDL auto-generation. | ||
|
||
### Basic: | ||
```bash | ||
curl -X GET http://localhost:8080/simple-greet | ||
Hello World! | ||
``` | ||
|
||
### JSON: | ||
```bash | ||
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 | ||
```bash | ||
curl -s -X GET http://localhost:8080/health | ||
{"outcome":"UP",... | ||
``` | ||
|
||
### Try metrics | ||
```bash | ||
# 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":... | ||
. . . | ||
``` | ||
|
||
## Building a Native Image | ||
|
||
The generation of native binaries requires an installation of GraalVM 22.1.0+. | ||
You can build a native binary using Maven as follows: | ||
|
||
```bash | ||
mvn -Pnative-image install -DskipTests | ||
``` | ||
|
||
The generation of the executable binary may take a few minutes to complete depending on your hardware and operating system. When completed, the executable file will be available under the `target` directory and be named after the artifact ID you have chosen during the project generation phase. | ||
|
||
## Docker Support | ||
|
||
### Building the Docker Image | ||
```bash | ||
docker build -t customer-helidon . | ||
``` | ||
|
||
### Running the Docker Image | ||
```bash | ||
docker run --rm -p 8080:8080 customer-helidon:latest | ||
``` | ||
|
||
Exercise the application as described above. | ||
|
||
## Configuration | ||
|
||
### Application Properties (`application.yaml`) | ||
```yaml | ||
# Microprofile server properties | ||
server.port=8080 | ||
server.host=0.0.0.0 | ||
# Change the following to true to enable the optional MicroProfile Metrics REST.request metrics | ||
metrics.rest-request.enabled=false | ||
|
||
# Application properties. This is the default greeting | ||
app.greeting=Hello | ||
|
||
# Database connection factory - specifies Oracle UCP driver for connection pooling | ||
javax.sql.DataSource.customer.connectionFactoryClassName = oracle.jdbc.pool.OracleDataSource | ||
|
||
# Local Oracle Database Configuration | ||
# Uncomment the following lines to connect to a local Oracle Docker container out-of-the-box: | ||
# javax.sql.DataSource.customer.URL = jdbc:oracle:thin:@//localhost:1521/freepdb1 | ||
# javax.sql.DataSource.customer.user = customer | ||
# javax.sql.DataSource.customer.password = Welcome12345 | ||
|
||
# Hibernate/JPA Configuration | ||
hibernate.hbm2ddl.auto=create | ||
hibernate.show_sql=true | ||
hibernate.format_sql=true | ||
# Fix JTA transaction coordinator issue | ||
hibernate.transaction.coordinator_class=jta | ||
|
||
# Eureka service discovery configuration | ||
server.features.eureka.client.base-uri=http://eureka.eureka:8761/eureka | ||
server.features.eureka.instance.name=helidon-customer-service | ||
server.features.eureka.instance.hostName=helidon.helidon | ||
``` | ||
|
||
## Build Architecture | ||
|
||
This project uses: | ||
- **Helidon MP (MicroProfile)** - Enterprise Java microservices profile | ||
- **Thin JAR deployment** - Application JAR + separate dependencies for optimal Docker layering | ||
- **Maven Assembly Plugin** - Creates deployment ZIP with proper structure for containerization | ||
- **Hibernate + JTA** - Database persistence with transaction management | ||
- **Oracle UCP** - Connection pooling for Oracle Database | ||
- **Eureka integration** - Service discovery support | ||
|
||
## Dockerfile Structure | ||
|
||
The included Dockerfile uses a **multi-stage build**: | ||
|
||
```dockerfile | ||
# 1st stage, build the app | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build | ||
|
||
# Install maven | ||
WORKDIR /usr/share | ||
RUN set -x && \ | ||
curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ | ||
tar -xvf apache-maven-*-bin.tar.gz && \ | ||
rm apache-maven-*-bin.tar.gz && \ | ||
mv apache-maven-* maven && \ | ||
ln -s /usr/share/maven/bin/mvn /bin/ | ||
|
||
WORKDIR /helidon | ||
|
||
# Create a first layer to cache the "Maven World" in the local repository. | ||
ADD pom.xml . | ||
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip -DskipOpenApiGenerate | ||
|
||
# Do the Maven build with fat JAR! | ||
ADD src src | ||
RUN mvn package -DskipTests | ||
|
||
# 2nd stage, build the runtime image | ||
FROM container-registry.oracle.com/java/jdk-no-fee-term:21 | ||
WORKDIR /helidon | ||
|
||
# Copy ONLY the fat JAR (not libs directory) | ||
COPY --from=build /helidon/target/*.jar app.jar | ||
|
||
# Simple fat JAR execution | ||
CMD ["java", "-jar", "app.jar"] | ||
EXPOSE 8080 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.