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

Instance Pool + Micronaut 4 #68

Merged
merged 13 commits into from
Dec 11, 2023
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
11 changes: 10 additions & 1 deletion basis/bin/build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [ -d src/db ]; then
fi

# Init target/compute
if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
mkdir -p target/compute
cp src/compute/* target/compute/.
fi
Expand All @@ -55,10 +55,19 @@ fi
title "Deploy $TF_VAR_deploy_strategy"
if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
$BIN_DIR/deploy_compute.sh
exit_on_error
elif [ "$TF_VAR_deploy_strategy" == "instance_pool" ]; then
$BIN_DIR/deploy_compute.sh
exit_on_error
export TF_VAR_compute_ready="true"
src/terraform/apply.sh --auto-approve -no-color
exit_on_error
elif [ "$TF_VAR_deploy_strategy" == "kubernetes" ]; then
$BIN_DIR/oke_deploy.sh
exit_on_error
elif [ "$TF_VAR_deploy_strategy" == "container_instance" ]; then
$BIN_DIR/ci_deploy.sh
exit_on_error
fi

$BIN_DIR/add_api_portal.sh
Expand Down
12 changes: 11 additions & 1 deletion basis/bin/shared_bash_function.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ java_build_common() {

build_ui() {
cd $SCRIPT_DIR
if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
mkdir -p ../../target/compute/ui
cp -r ui/* ../../target/compute/ui/.
elif [ "$TF_VAR_deploy_strategy" == "function" ]; then
Expand Down Expand Up @@ -236,13 +236,23 @@ get_user_details() {
get_ui_url() {
if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
get_output_from_tfstate UI_URL ui_url
elif [ "$TF_VAR_deploy_strategy" == "instance_pool" ]; then
get_output_from_tfstate UI_URL pool_lb_url
elif [ "$TF_VAR_deploy_strategy" == "kubernetes" ]; then
export UI_URL=http://`kubectl get service -n ingress-nginx ingress-nginx-controller -o jsonpath="{.status.loadBalancer.ingress[0].ip}"`/${TF_VAR_prefix}
elif [ "$TF_VAR_deploy_strategy" == "function" ] || [ "$TF_VAR_deploy_strategy" == "container_instance" ]; then
export UI_URL=https://${APIGW_HOSTNAME}/${TF_VAR_prefix}
fi
}

is_deploy_compute() {
if [ "$TF_VAR_deploy_strategy" == "compute" ] || [ "$TF_VAR_deploy_strategy" == "instance_pool" ]; then
return 0
else
return 1
fi
}

livelabs_green_button() {
# Lot of tests to be sure we are in a empty Green Button LiveLabs
# compartment_ocid still undefined ?
Expand Down
2 changes: 1 addition & 1 deletion basis/src/app/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

## XXXXX Check Language version

if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
mkdir -p ../../target/compute/$APP_DIR
cp -r src/* ../../target/compute/$APP_DIR/.
# Replace the user and password in the start file
Expand Down
2 changes: 1 addition & 1 deletion option/src/app/apex/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
. $SCRIPT_DIR/../../env.sh -no-auto
. $BIN_DIR/build_common.sh

if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
sed "s&##ORDS_URL##&$ORDS_URL&" nginx_app.locations > ../../target/compute/nginx_app.locations
ORDS_HOST=`basename $(dirname $ORDS_URL)`
sed -i "s&##ORDS_HOST##&$ORDS_HOST&" ../../target/compute/nginx_app.locations
Expand Down
Empty file modified option/src/app/forms/domainconfig.sh
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion option/src/app/java_helidon/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then
sed -i "s&##JDBC_URL##&$JDBC_URL&" src/main/resources/META-INF/microprofile-config.properties
fi

if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
# -Dnet.bytebuddy.experimental=true is needed in helidon 3 for Java 21
if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then
mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests -Dnet.bytebuddy.experimental=true
Expand Down
2 changes: 1 addition & 1 deletion option/src/app/java_helidon4/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then
sed -i "s&##JDBC_URL##&$JDBC_URL&" src/main/resources/META-INF/microprofile-config.properties
fi

if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then
mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests
else
Expand Down
File renamed without changes.
38 changes: 32 additions & 6 deletions option/src/app/java_micronaut/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
## Micronaut 3.7.4 Documentation
## Micronaut 4.2.1 Documentation

- [User Guide](https://docs.micronaut.io/3.7.4/guide/index.html)
- [API Reference](https://docs.micronaut.io/3.7.4/api/index.html)
- [Configuration Reference](https://docs.micronaut.io/3.7.4/guide/configurationreference.html)
- [User Guide](https://docs.micronaut.io/4.2.1/guide/index.html)
- [API Reference](https://docs.micronaut.io/4.2.1/api/index.html)
- [Configuration Reference](https://docs.micronaut.io/4.2.1/guide/configurationreference.html)
- [Micronaut Guides](https://guides.micronaut.io/index.html)
---

## Feature http-client documentation
- [Micronaut Maven Plugin documentation](https://micronaut-projects.github.io/micronaut-maven-plugin/latest/)
## Feature hibernate-jpa documentation

- [Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient)
- [Micronaut Hibernate JPA documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#hibernate)


## Feature annotation-api documentation

- [https://jakarta.ee/specifications/annotations/](https://jakarta.ee/specifications/annotations/)


## Feature jdbc-hikari documentation

- [Micronaut Hikari JDBC Connection Pool documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#jdbc)


## Feature test-resources documentation

- [Micronaut Test Resources documentation](https://micronaut-projects.github.io/micronaut-test-resources/latest/guide/)


## Feature micronaut-aot documentation

- [Micronaut AOT documentation](https://micronaut-projects.github.io/micronaut-aot/latest/guide/)


## Feature maven-enforcer-plugin documentation

- [https://maven.apache.org/enforcer/maven-enforcer-plugin/](https://maven.apache.org/enforcer/maven-enforcer-plugin/)


## Feature validation documentation

- [Micronaut Validation documentation](https://micronaut-projects.github.io/micronaut-validation/latest/guide/)


34 changes: 34 additions & 0 deletions option/src/app/java_micronaut/aot-jar.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# AOT configuration properties for jar packaging
# Please review carefully the optimizations enabled below
# Check https://micronaut-projects.github.io/micronaut-aot/latest/guide/ for more details

# Caches environment property values: environment properties will be deemed immutable after application startup.
cached.environment.enabled=true

# Precomputes Micronaut configuration property keys from the current environment variables
precompute.environment.properties.enabled=true

# Converts YAML configuration files to Java configuration
yaml.to.java.config.enabled=true

# Scans for service types ahead-of-time, avoiding classpath scanning at startup
serviceloading.jit.enabled=true

# Scans reactive types at build time instead of runtime
scan.reactive.types.enabled=true

# Deduces the environment at build time instead of runtime
deduce.environment.enabled=true

# Checks of existence of some types at build time instead of runtime
known.missing.types.enabled=true

# Precomputes property sources at build time
sealed.property.source.enabled=true

# The list of service types to be scanned (comma separated)
service.types=io.micronaut.context.env.PropertySourceLoader,io.micronaut.inject.BeanConfiguration,io.micronaut.inject.BeanDefinitionReference,io.micronaut.http.HttpRequestFactory,io.micronaut.http.HttpResponseFactory,io.micronaut.core.beans.BeanIntrospectionReference,io.micronaut.core.convert.TypeConverterRegistrar,io.micronaut.context.env.PropertyExpressionResolver

# A list of types that the AOT analyzer needs to check for existence (comma separated)
known.missing.types.list=io.reactivex.Observable,reactor.core.publisher.Flux,kotlinx.coroutines.flow.Flow,io.reactivex.rxjava3.core.Flowable,io.reactivex.rxjava3.core.Observable,io.reactivex.Single,reactor.core.publisher.Mono,io.reactivex.Maybe,io.reactivex.rxjava3.core.Single,io.reactivex.rxjava3.core.Maybe,io.reactivex.Completable,io.reactivex.rxjava3.core.Completable,io.methvin.watchservice.MacOSXListeningWatchService,io.micronaut.core.async.publisher.CompletableFuturePublisher,io.micronaut.core.async.publisher.Publishers.JustPublisher,io.micronaut.core.async.subscriber.Completable

2 changes: 1 addition & 1 deletion option/src/app/java_micronaut/build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
fi
exit_on_error

if [ "$TF_VAR_deploy_strategy" == "compute" ]; then
if is_deploy_compute; then
cp start.sh install.sh target/.

mkdir -p ../../target/compute/$APP_DIR
Expand Down
2 changes: 2 additions & 0 deletions option/src/app/java_micronaut/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Install the JVM (jdk or graalvm)
install_java
2 changes: 1 addition & 1 deletion option/src/app/java_micronaut/micronaut-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ defaultPackage: com.example
testFramework: junit
sourceLanguage: java
buildTool: maven
features: [annotation-api, app-name, data, data-jpa, graalvm, h2, http-client, jackson-databind, java, java-application, jdbc-hikari, junit, logback, maven, netty-server, readme, shade, yaml]
features: [annotation-api, app-name, data, data-jpa, hibernate-jpa, http-client-test, jackson-databind, java, java-application, jdbc-hikari, junit, logback, maven, maven-enforcer-plugin, micronaut-aot, micronaut-http-validation, netty-server, oracle, properties, readme, shade, test-resources, validation]
22 changes: 22 additions & 0 deletions option/src/app/java_micronaut/micronaut_refresh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
echo "Refresh the sample Micronaut application"
echo
mkdir orig
mv * orig



curl --location --request GET 'https://launch.micronaut.io/create/default/com.example.demo?lang=JAVA&build=MAVEN&test=JUNIT&javaVersion=JDK_17&features=oracle&features=netty-server&features=hibernate-jpa&features=validation&features=jackson-databind&features=annotation-api&features=data-jpa' --output demo.zip
unzip demo.zip
mv demo/* .
mv demo/.* .
rmdir demo

cp orig/*.sh .
cp orig/openapi_spec.yaml .
cp orig/app.yaml .
cp orig/src/main/java/com/example/Dept* src/main/java/com/example/.
cp orig/microprofile-config.properties.tmpl .
cp orig/Docker* .
cp orig/src/main/resources/application.j2.yml src/main/resources/.
rm src/main/resources/application.properties

39 changes: 39 additions & 0 deletions option/src/app/java_micronaut/openapi_spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
openapi: 3.0.0
info:
title: Dept API
version: 1.0.0
paths:
/app/dept:
get:
summary: Rest DB API
operationId: dept
responses:
'200':
description: List of departments
content:
application/json:
schema:
type: array
items:
type: object
properties:
deptno:
type: integer
format: int32
description: Department number
dname:
type: string
description: Department name
loc:
type: string
description: Location
/app/info:
get:
summary: Rest Info API
responses:
200:
description: Information about the API
content:
text/html:
schema:
type: string
Loading