From e6cac85831002c930b4cdfb6f4ca101f7be86adb Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sat, 9 Dec 2023 17:41:48 +0100 Subject: [PATCH 01/13] v1.6 --- basis/bin/build_all.sh | 9 ++ option/terraform/instance_pool.tf | 162 ++++++++++++++++++++++++++++++ py_oci_starter.py | 13 +-- 3 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 option/terraform/instance_pool.tf diff --git a/basis/bin/build_all.sh b/basis/bin/build_all.sh index 1b726dad..6222c050 100755 --- a/basis/bin/build_all.sh +++ b/basis/bin/build_all.sh @@ -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 diff --git a/option/terraform/instance_pool.tf b/option/terraform/instance_pool.tf new file mode 100644 index 00000000..c79c9b1e --- /dev/null +++ b/option/terraform/instance_pool.tf @@ -0,0 +1,162 @@ +variable compute_ready { default = "ready" } + +resource "oci_core_image" "custom_image" { + count = var.compute_ready == "" ? 0 : 1 + compartment_id = local.lz_appdev_cmp_ocid + instance_id = oci_core_instance.starter_instance.id + launch_mode = "NATIVE" + display_name = "${var.prefix}-image" + freeform_tags = local.freeform_tags + + timeouts { + create = "30m" + } +} + +resource "oci_load_balancer" "starter_pool_lb" { + shape = "flexible" + compartment_id = local.lz_appdev_cmp_ocid + subnet_ids = [ data.oci_core_subnet.starter_public_subnet.id ] + shape_details { + #Required + minimum_bandwidth_in_mbps = 10 + maximum_bandwidth_in_mbps = 100 + } + + display_name ="${var.prefix}-pool-lb" +} + +resource "oci_load_balancer_backend_set" "starter_pool_backend_set" { + name = "${substr(var.prefix,0,8)}-pool-bes" + load_balancer_id = oci_load_balancer.starter_pool_lb.id + policy = "ROUND_ROBIN" + + health_checker { + port = "80" + protocol = "HTTP" + response_body_regex = ".*" + url_path = "/" + } +} + +resource "oci_load_balancer_listener" "starter_pool_lb_listener" { + load_balancer_id = oci_load_balancer.starter_pool_lb.id + name = "http" + default_backend_set_name = oci_load_balancer_backend_set.starter_pool_backend_set.name + port = 80 + protocol = "HTTP" +} + +resource "oci_core_instance_configuration" "starter_instance_configuration" { + count = var.compute_ready == "" ? 0 : 1 + compartment_id = local.lz_appdev_cmp_ocid + display_name = "${var.prefix}-instance-config" + + instance_details { + instance_type = "compute" + + launch_details { + availability_domain = data.oci_identity_availability_domain.ad.name + compartment_id = local.lz_appdev_cmp_ocid + display_name = "${var.prefix}-launch-details" + shape = var.instance_shape + + shape_config { + ocpus = var.instance_ocpus + memory_in_gbs = var.instance_shape_config_memory_in_gbs + # baseline_ocpu_utilization = "BASELINE_1_8" + } + + create_vnic_details { + subnet_id = data.oci_core_subnet.starter_public_subnet.id + display_name = "Primaryvnic" + assign_public_ip = true + assign_private_dns_record = true + hostname_label = "${var.prefix}-instance" + } + + # XXXX Should be there only for Java + agent_config { + plugins_config { + desired_state = "ENABLED" + name = "Oracle Java Management Service" + } + plugins_config { + desired_state = "ENABLED" + name = "Management Agent" + } + } + + metadata = { + ssh_authorized_keys = var.ssh_public_key + } + + source_details { + source_type = "image" + image_id = oci_core_image.custom_image[0].id + } + + freeform_tags = local.freeform_tags + } + + } +} + +resource "oci_core_instance_pool" "starter_instance_pool" { + count = var.compute_ready == "" ? 0 : 1 + compartment_id = local.lz_appdev_cmp_ocid + instance_configuration_id = oci_core_instance_configuration.starter_instance_configuration[0].id + size = 2 + state = "RUNNING" + display_name = "${var.prefix}-pool" + instance_display_name_formatter = "${var.prefix}-host$${launchCount}" + instance_hostname_formatter = "${var.prefix}-host$${launchCount}" + + placement_configurations { + availability_domain = data.oci_identity_availability_domain.ad.name + primary_subnet_id = data.oci_core_subnet.starter_public_subnet.id + } + + load_balancers { + load_balancer_id = oci_load_balancer.starter_pool_lb.id + backend_set_name = oci_load_balancer_backend_set.starter_pool_backend_set.name + port = 80 + vnic_selection = "primaryvnic" + } + + lifecycle { + ignore_changes = [size] + } +} + +data "oci_core_instance_pool_instances" "starter_instance_pool_instances_datasource" { + compartment_id = local.lz_appdev_cmp_ocid + instance_pool_id = oci_core_instance_pool.starter_instance_pool[0].id +} + +# Usage of singular instance datasources to show the public_ips, private_ips, and hostname_labels for the instances in the pool +data "oci_core_instance" "starter_instance_pool_instance_singular_datasource" { + count = 2 + instance_id = data.oci_core_instance_pool_instances.starter_instance_pool_instances_datasource.instances[count.index]["id"] +} + +data "oci_core_instance_pool_load_balancer_attachment" "starter_instance_pool_load_balancer_attachment" { + instance_pool_id = oci_core_instance_pool.starter_instance_pool[0].id + instance_pool_load_balancer_attachment_id = oci_core_instance_pool.starter_instance_pool[0].load_balancers[0].id +} + +output "pooled_instances_private_ips" { + value = [data.oci_core_instance.starter_instance_pool_instance_singular_datasource.*.private_ip] +} + +output "pooled_instances_public_ips" { + value = [data.oci_core_instance.starter_instance_pool_instance_singular_datasource.*.public_ip] +} + +output "pooled_instances_hostname_labels" { + value = [data.oci_core_instance.starter_instance_pool_instance_singular_datasource.*.hostname_label] +} + +output "load_balancer_backend_set_name" { + value = [data.oci_core_instance_pool_load_balancer_attachment.starter_instance_pool_load_balancer_attachment.backend_set_name] +} \ No newline at end of file diff --git a/py_oci_starter.py b/py_oci_starter.py index ede44945..34f0ca09 100755 --- a/py_oci_starter.py +++ b/py_oci_starter.py @@ -94,7 +94,7 @@ def allowed_options(): allowed_values = { '-language': {'java', 'node', 'python', 'dotnet', 'go', 'php', 'ords', 'apex', 'forms', 'none'}, - '-deploy': {'compute', 'kubernetes', 'function', 'container_instance', 'ci', 'hpc', 'datascience'}, + '-deploy': {'compute', 'instance_pool', 'kubernetes', 'function', 'container_instance', 'hpc', 'datascience'}, '-java_framework': {'springboot', 'helidon', 'helidon4', 'tomcat', 'micronaut'}, '-java_vm': {'jdk', 'graalvm', 'graalvm-native'}, '-java_version': {'8', '11', '17', '21'}, @@ -202,9 +202,8 @@ def ui_rules(): elif params.get('ui') == 'ruby': params['language'] = 'ruby' - def auth_token_rules(): - if params.get('deploy') not in [ 'compute', 'hpc', 'datascience' ] and params.get('auth_token') is None: + if params.get('deploy') in [ 'kubernetes', 'container_instance', 'function' ] and params.get('auth_token') is None: warning('-auth_token is not set. Will need to be set in env.sh') params['auth_token'] = TO_FILL @@ -418,7 +417,7 @@ def readme_contents(): - db : SQL files of the database - terraform : Terraform scripts (Command: plan.sh / apply.sh)''' ] - if params['deploy'] == 'compute': + if params['deploy'] in [ 'compute', 'instance_pool' ]: contents.append( " - compute : Contains the deployment files to Compute") elif params['deploy'] == 'kubernetes': @@ -754,7 +753,7 @@ def create_output_dir(): elif params.get('ui') == "api": print("API Only") output_rm_tree("src/ui") - if params.get('deploy') == "compute": + if params.get('deploy') in [ 'compute', 'instance_pool' ]: cp_terraform_apigw("apigw_compute_append.tf") else: ui_lower = params.get('ui').lower() @@ -808,7 +807,7 @@ def create_output_dir(): else: cp_terraform("apigw.tf", "apigw_tags.tf", apigw_append) - elif params.get('deploy') == "compute": + elif params.get('deploy') in [ 'compute', 'instance_pool' ]: if 'compute_ocid' in params: cp_terraform("compute_existing.tf", "compute_append.tf") elif params.get("language") == 'forms': @@ -817,6 +816,8 @@ def create_output_dir(): cp_terraform("compute.tf", "compute_append.tf") output_mkdir("src/compute") output_copy_tree("option/compute", "src/compute") + if params.get('deploy') == 'instance_pool': + cp_terraform("instance_pool.tf") elif params.get('deploy') == "container_instance": if 'group_common' not in params: From a265659a8dd212fe83f8456c9a9b98cd3a5cfc1c Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sat, 9 Dec 2023 18:27:43 +0100 Subject: [PATCH 02/13] v1.6 --- basis/bin/build_all.sh | 2 +- basis/bin/shared_bash_function.sh | 12 +++++++++++- basis/src/app/build_app.sh | 2 +- option/src/app/apex/build_app.sh | 2 +- option/src/app/java_helidon/build_app.sh | 2 +- option/src/app/java_helidon4/build_app.sh | 2 +- option/src/app/java_micronaut/build_app.sh | 2 +- option/src/app/java_springboot/build_app.sh | 2 +- option/src/app/java_tomcat/build_app.sh | 2 +- option/src/app/ords/build_app.sh | 2 +- option/src/app/php/build_app.sh | 2 +- option/terraform/instance_pool.tf | 8 ++++++-- 12 files changed, 27 insertions(+), 13 deletions(-) diff --git a/basis/bin/build_all.sh b/basis/bin/build_all.sh index 6222c050..fbc2428b 100755 --- a/basis/bin/build_all.sh +++ b/basis/bin/build_all.sh @@ -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 diff --git a/basis/bin/shared_bash_function.sh b/basis/bin/shared_bash_function.sh index 62d6bb26..b4aed306 100755 --- a/basis/bin/shared_bash_function.sh +++ b/basis/bin/shared_bash_function.sh @@ -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 @@ -236,6 +236,8 @@ 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 @@ -243,6 +245,14 @@ get_ui_url() { 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 ? diff --git a/basis/src/app/build_app.sh b/basis/src/app/build_app.sh index 46509399..9493ecae 100755 --- a/basis/src/app/build_app.sh +++ b/basis/src/app/build_app.sh @@ -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 diff --git a/option/src/app/apex/build_app.sh b/option/src/app/apex/build_app.sh index 5e99d8b5..c33fa5df 100755 --- a/option/src/app/apex/build_app.sh +++ b/option/src/app/apex/build_app.sh @@ -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 diff --git a/option/src/app/java_helidon/build_app.sh b/option/src/app/java_helidon/build_app.sh index cb65b399..c4055f65 100755 --- a/option/src/app/java_helidon/build_app.sh +++ b/option/src/app/java_helidon/build_app.sh @@ -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 diff --git a/option/src/app/java_helidon4/build_app.sh b/option/src/app/java_helidon4/build_app.sh index b39a0619..69aeb727 100755 --- a/option/src/app/java_helidon4/build_app.sh +++ b/option/src/app/java_helidon4/build_app.sh @@ -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 diff --git a/option/src/app/java_micronaut/build_app.sh b/option/src/app/java_micronaut/build_app.sh index 08131dc6..a0b4e6d9 100755 --- a/option/src/app/java_micronaut/build_app.sh +++ b/option/src/app/java_micronaut/build_app.sh @@ -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 diff --git a/option/src/app/java_springboot/build_app.sh b/option/src/app/java_springboot/build_app.sh index 88099ae2..58a2583d 100755 --- a/option/src/app/java_springboot/build_app.sh +++ b/option/src/app/java_springboot/build_app.sh @@ -12,7 +12,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) . $BIN_DIR/build_common.sh java_build_common -if [ "$TF_VAR_deploy_strategy" == "compute" ]; then +if [ is_deploy_compute ]; then if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then # Native Build about 14 mins. Output is ./demo diff --git a/option/src/app/java_tomcat/build_app.sh b/option/src/app/java_tomcat/build_app.sh index a5b2193f..0c8c6a02 100755 --- a/option/src/app/java_tomcat/build_app.sh +++ b/option/src/app/java_tomcat/build_app.sh @@ -15,7 +15,7 @@ java_build_common mvn package exit_on_error -if [ "$TF_VAR_deploy_strategy" == "compute" ]; then +if [ is_deploy_compute ]; then cp src/start.sh target/. cp src/install.sh target/. diff --git a/option/src/app/ords/build_app.sh b/option/src/app/ords/build_app.sh index 4af79b02..f0f79c4d 100755 --- a/option/src/app/ords/build_app.sh +++ b/option/src/app/ords/build_app.sh @@ -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 else echo "No docker image needed" diff --git a/option/src/app/php/build_app.sh b/option/src/app/php/build_app.sh index b726ce68..84009872 100755 --- a/option/src/app/php/build_app.sh +++ b/option/src/app/php/build_app.sh @@ -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 diff --git a/option/terraform/instance_pool.tf b/option/terraform/instance_pool.tf index c79c9b1e..493503a2 100644 --- a/option/terraform/instance_pool.tf +++ b/option/terraform/instance_pool.tf @@ -109,8 +109,8 @@ resource "oci_core_instance_pool" "starter_instance_pool" { size = 2 state = "RUNNING" display_name = "${var.prefix}-pool" - instance_display_name_formatter = "${var.prefix}-host$${launchCount}" - instance_hostname_formatter = "${var.prefix}-host$${launchCount}" + instance_display_name_formatter = "${var.prefix}-pool$${launchCount}" + instance_hostname_formatter = "${var.prefix}-pool$${launchCount}" placement_configurations { availability_domain = data.oci_identity_availability_domain.ad.name @@ -159,4 +159,8 @@ output "pooled_instances_hostname_labels" { output "load_balancer_backend_set_name" { value = [data.oci_core_instance_pool_load_balancer_attachment.starter_instance_pool_load_balancer_attachment.backend_set_name] +} + +output "pool_lb_url" { + value = format("http://%s", oci_load_balancer.starter_pool_lb.ip_address_details[0].ip_address) } \ No newline at end of file From fb386efe9c7d30151c1ea324ebb47f5b12299977 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sat, 9 Dec 2023 18:28:28 +0100 Subject: [PATCH 03/13] v1.6 --- basis/bin/build_all.sh | 2 +- basis/bin/shared_bash_function.sh | 2 +- basis/src/app/build_app.sh | 2 +- option/src/app/apex/build_app.sh | 2 +- option/src/app/java_helidon/build_app.sh | 2 +- option/src/app/java_helidon4/build_app.sh | 2 +- option/src/app/java_micronaut/build_app.sh | 2 +- option/src/app/java_springboot/build_app.sh | 2 +- option/src/app/java_tomcat/build_app.sh | 2 +- option/src/app/ords/build_app.sh | 2 +- option/src/app/php/build_app.sh | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/basis/bin/build_all.sh b/basis/bin/build_all.sh index fbc2428b..018493fe 100755 --- a/basis/bin/build_all.sh +++ b/basis/bin/build_all.sh @@ -33,7 +33,7 @@ if [ -d src/db ]; then fi # Init target/compute -if [ is_deploy_compute ]; then +if is_deploy_compute; then mkdir -p target/compute cp src/compute/* target/compute/. fi diff --git a/basis/bin/shared_bash_function.sh b/basis/bin/shared_bash_function.sh index b4aed306..f6706bcf 100755 --- a/basis/bin/shared_bash_function.sh +++ b/basis/bin/shared_bash_function.sh @@ -32,7 +32,7 @@ java_build_common() { build_ui() { cd $SCRIPT_DIR - if [ is_deploy_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 diff --git a/basis/src/app/build_app.sh b/basis/src/app/build_app.sh index 9493ecae..40316356 100755 --- a/basis/src/app/build_app.sh +++ b/basis/src/app/build_app.sh @@ -13,7 +13,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ## XXXXX Check Language version -if [ is_deploy_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 diff --git a/option/src/app/apex/build_app.sh b/option/src/app/apex/build_app.sh index c33fa5df..65fd55e9 100755 --- a/option/src/app/apex/build_app.sh +++ b/option/src/app/apex/build_app.sh @@ -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 [ is_deploy_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 diff --git a/option/src/app/java_helidon/build_app.sh b/option/src/app/java_helidon/build_app.sh index c4055f65..2d1a9523 100755 --- a/option/src/app/java_helidon/build_app.sh +++ b/option/src/app/java_helidon/build_app.sh @@ -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 [ is_deploy_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 diff --git a/option/src/app/java_helidon4/build_app.sh b/option/src/app/java_helidon4/build_app.sh index 69aeb727..1f27d6a6 100755 --- a/option/src/app/java_helidon4/build_app.sh +++ b/option/src/app/java_helidon4/build_app.sh @@ -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 [ is_deploy_compute ]; then +if is_deploy_compute; then if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then mvn package -Pnative-image -Dnative.image.buildStatic -DskipTests else diff --git a/option/src/app/java_micronaut/build_app.sh b/option/src/app/java_micronaut/build_app.sh index a0b4e6d9..9294c56b 100755 --- a/option/src/app/java_micronaut/build_app.sh +++ b/option/src/app/java_micronaut/build_app.sh @@ -19,7 +19,7 @@ else fi exit_on_error -if [ is_deploy_compute ]; then +if is_deploy_compute; then cp start.sh install.sh target/. mkdir -p ../../target/compute/$APP_DIR diff --git a/option/src/app/java_springboot/build_app.sh b/option/src/app/java_springboot/build_app.sh index 58a2583d..6b399572 100755 --- a/option/src/app/java_springboot/build_app.sh +++ b/option/src/app/java_springboot/build_app.sh @@ -12,7 +12,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) . $BIN_DIR/build_common.sh java_build_common -if [ is_deploy_compute ]; then +if is_deploy_compute; then if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then # Native Build about 14 mins. Output is ./demo diff --git a/option/src/app/java_tomcat/build_app.sh b/option/src/app/java_tomcat/build_app.sh index 0c8c6a02..af32657f 100755 --- a/option/src/app/java_tomcat/build_app.sh +++ b/option/src/app/java_tomcat/build_app.sh @@ -15,7 +15,7 @@ java_build_common mvn package exit_on_error -if [ is_deploy_compute ]; then +if is_deploy_compute; then cp src/start.sh target/. cp src/install.sh target/. diff --git a/option/src/app/ords/build_app.sh b/option/src/app/ords/build_app.sh index f0f79c4d..0ac0ea24 100755 --- a/option/src/app/ords/build_app.sh +++ b/option/src/app/ords/build_app.sh @@ -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 [ is_deploy_compute ]; then +if is_deploy_compute; then sed "s&##ORDS_URL##&$ORDS_URL&" nginx_app.locations > ../../target/compute/nginx_app.locations else echo "No docker image needed" diff --git a/option/src/app/php/build_app.sh b/option/src/app/php/build_app.sh index 84009872..5e1313a6 100755 --- a/option/src/app/php/build_app.sh +++ b/option/src/app/php/build_app.sh @@ -13,7 +13,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) ## XXXXX Check Language version -if [ is_deploy_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 From 0028de0de6db3c4efb5d18525eb57213c1c4a9dc Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sun, 10 Dec 2023 10:55:01 +0100 Subject: [PATCH 04/13] v1.6 --- option/terraform/instance_pool.tf | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/option/terraform/instance_pool.tf b/option/terraform/instance_pool.tf index 493503a2..5ff500ef 100644 --- a/option/terraform/instance_pool.tf +++ b/option/terraform/instance_pool.tf @@ -1,4 +1,4 @@ -variable compute_ready { default = "ready" } +variable compute_ready { default = "" } resource "oci_core_image" "custom_image" { count = var.compute_ready == "" ? 0 : 1 @@ -130,19 +130,15 @@ resource "oci_core_instance_pool" "starter_instance_pool" { } data "oci_core_instance_pool_instances" "starter_instance_pool_instances_datasource" { + count = var.compute_ready == "" ? 0 : 1 compartment_id = local.lz_appdev_cmp_ocid instance_pool_id = oci_core_instance_pool.starter_instance_pool[0].id } # Usage of singular instance datasources to show the public_ips, private_ips, and hostname_labels for the instances in the pool data "oci_core_instance" "starter_instance_pool_instance_singular_datasource" { - count = 2 - instance_id = data.oci_core_instance_pool_instances.starter_instance_pool_instances_datasource.instances[count.index]["id"] -} - -data "oci_core_instance_pool_load_balancer_attachment" "starter_instance_pool_load_balancer_attachment" { - instance_pool_id = oci_core_instance_pool.starter_instance_pool[0].id - instance_pool_load_balancer_attachment_id = oci_core_instance_pool.starter_instance_pool[0].load_balancers[0].id + count = var.compute_ready == "" ? 0 : 2 + instance_id = data.oci_core_instance_pool_instances.starter_instance_pool_instances_datasource[0].instances[count.index]["id"] } output "pooled_instances_private_ips" { @@ -157,10 +153,6 @@ output "pooled_instances_hostname_labels" { value = [data.oci_core_instance.starter_instance_pool_instance_singular_datasource.*.hostname_label] } -output "load_balancer_backend_set_name" { - value = [data.oci_core_instance_pool_load_balancer_attachment.starter_instance_pool_load_balancer_attachment.backend_set_name] -} - output "pool_lb_url" { value = format("http://%s", oci_load_balancer.starter_pool_lb.ip_address_details[0].ip_address) } \ No newline at end of file From 306ddb72ccae069e035a7d3bb639f3be3b491f72 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sun, 10 Dec 2023 18:43:47 +0100 Subject: [PATCH 05/13] v1.6 --- option/src/app/php/src/install.j2.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/option/src/app/php/src/install.j2.sh b/option/src/app/php/src/install.j2.sh index 5b472744..bd847790 100755 --- a/option/src/app/php/src/install.j2.sh +++ b/option/src/app/php/src/install.j2.sh @@ -32,7 +32,9 @@ sudo cp app.conf /etc/httpd/conf.d/. # Configure the Apache Listener on 8080 sudo sed -i "s/Listen 80$/Listen 8080/" /etc/httpd/conf/httpd.conf +sudo systemctl enable httpd sudo systemctl restart httpd +sudo systemctl enable php-fpm sudo systemctl restart php-fpm # XXXX From 3c88b9042618411ffa65c64147cbcc22fff5fd5c Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Sun, 10 Dec 2023 18:54:35 +0100 Subject: [PATCH 06/13] v1.6 --- option/test_suite_group_all.sh | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/option/test_suite_group_all.sh b/option/test_suite_group_all.sh index 64c228f2..79f8f5e5 100755 --- a/option/test_suite_group_all.sh +++ b/option/test_suite_group_all.sh @@ -46,14 +46,16 @@ loop_shape() { loop_db() { OPTION_DB_INSTALL=default - # OPTION_DB=database - # loop_ui - OPTION_DB=atp - loop_shape - OPTION_DB=psql - loop_shape - OPTION_DB=mysql - loop_shape + if [ "$OPTION_DEPLOY" != "instance_pool" ] ; then + # OPTION_DB=database + # loop_ui + OPTION_DB=atp + loop_shape + OPTION_DB=psql + loop_shape + OPTION_DB=mysql + loop_shape + fi OPTION_DB=none loop_shape } @@ -140,12 +142,14 @@ loop_deploy() { OPTION_DEPLOY=compute loop_shared_compute loop_lang + OPTION_DEPLOY=kubernetes + loop_lang + OPTION_DEPLOY=instance_pool + loop_lang OPTION_DEPLOY=container_instance loop_lang OPTION_DEPLOY=function loop_lang - OPTION_DEPLOY=kubernetes - loop_lang } generate_only() { From 9bb3a61b45f247fd81359dcf947ea3c9b1aea9e7 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 12:13:42 +0100 Subject: [PATCH 07/13] v1.6 --- option/src/app/java_micronaut/README.md | 38 +++- .../src/app/java_micronaut/aot-jar.properties | 34 ++++ option/src/app/java_micronaut/install.sh | 2 + .../src/app/java_micronaut/micronaut-cli.yml | 2 +- .../src/app/java_micronaut/openapi_spec.yaml | 39 ++++ option/src/app/java_micronaut/pom.j2xml | 190 ++++++++++++++++++ .../app/java_micronaut/refresh_micronaut.sh | 26 +++ .../main/java/com/example/Application.java | 3 +- .../src/main/java/com/example/Dept.java | 2 +- .../main/java/com/example/DeptController.java | 5 +- .../main/java/com/example/DeptRepository.java | 4 +- .../src/main/resources/application.j2.yml | 3 +- .../resources/application.properties.orig | 6 + .../src/main/resources/logback.xml | 1 - .../resources/application-test.properties | 2 + option/src/app/java_micronaut3/.gitignore | 15 ++ .../Dockerfile | 0 .../Dockerfile.native | 0 option/src/app/java_micronaut3/README.md | 18 ++ option/src/app/java_micronaut3/app.yaml | 45 +++++ option/src/app/java_micronaut3/build_app.sh | 37 ++++ .../src/app/java_micronaut3/micronaut-cli.yml | 6 + .../pom.j2.xml | 0 .../app/java_micronaut3/refresh_micronaut.sh | 23 +++ .../main/java/com/example/Application.java | 9 + .../src/main/java/com/example/Dept.java | 55 +++++ .../main/java/com/example/DeptController.java | 36 ++++ .../main/java/com/example/DeptRepository.java | 22 ++ .../src/main/resources/application.j2.yml | 26 +++ .../src/main/resources/application_orig.yml | 0 .../src/main/resources/logback.xml | 15 ++ option/src/app/java_micronaut3/start.sh | 14 ++ 32 files changed, 661 insertions(+), 17 deletions(-) create mode 100644 option/src/app/java_micronaut/aot-jar.properties create mode 100755 option/src/app/java_micronaut/install.sh create mode 100644 option/src/app/java_micronaut/openapi_spec.yaml create mode 100644 option/src/app/java_micronaut/pom.j2xml create mode 100644 option/src/app/java_micronaut/refresh_micronaut.sh create mode 100644 option/src/app/java_micronaut/src/main/resources/application.properties.orig create mode 100644 option/src/app/java_micronaut/src/test/resources/application-test.properties create mode 100644 option/src/app/java_micronaut3/.gitignore rename option/src/app/{java_micronaut => java_micronaut3}/Dockerfile (100%) rename option/src/app/{java_micronaut => java_micronaut3}/Dockerfile.native (100%) create mode 100644 option/src/app/java_micronaut3/README.md create mode 100644 option/src/app/java_micronaut3/app.yaml create mode 100755 option/src/app/java_micronaut3/build_app.sh create mode 100644 option/src/app/java_micronaut3/micronaut-cli.yml rename option/src/app/{java_micronaut => java_micronaut3}/pom.j2.xml (100%) create mode 100644 option/src/app/java_micronaut3/refresh_micronaut.sh create mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/Application.java create mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/Dept.java create mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java create mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java create mode 100644 option/src/app/java_micronaut3/src/main/resources/application.j2.yml rename option/src/app/{java_micronaut => java_micronaut3}/src/main/resources/application_orig.yml (100%) create mode 100644 option/src/app/java_micronaut3/src/main/resources/logback.xml create mode 100755 option/src/app/java_micronaut3/start.sh diff --git a/option/src/app/java_micronaut/README.md b/option/src/app/java_micronaut/README.md index 5a32f049..a970cff0 100644 --- a/option/src/app/java_micronaut/README.md +++ b/option/src/app/java_micronaut/README.md @@ -1,14 +1,20 @@ -## 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 @@ -16,3 +22,23 @@ - [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/) + + diff --git a/option/src/app/java_micronaut/aot-jar.properties b/option/src/app/java_micronaut/aot-jar.properties new file mode 100644 index 00000000..71049dcb --- /dev/null +++ b/option/src/app/java_micronaut/aot-jar.properties @@ -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 + diff --git a/option/src/app/java_micronaut/install.sh b/option/src/app/java_micronaut/install.sh new file mode 100755 index 00000000..b84679fe --- /dev/null +++ b/option/src/app/java_micronaut/install.sh @@ -0,0 +1,2 @@ +# Install the JVM (jdk or graalvm) +install_java \ No newline at end of file diff --git a/option/src/app/java_micronaut/micronaut-cli.yml b/option/src/app/java_micronaut/micronaut-cli.yml index 6d8785b5..8a38eb81 100644 --- a/option/src/app/java_micronaut/micronaut-cli.yml +++ b/option/src/app/java_micronaut/micronaut-cli.yml @@ -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] diff --git a/option/src/app/java_micronaut/openapi_spec.yaml b/option/src/app/java_micronaut/openapi_spec.yaml new file mode 100644 index 00000000..803c9f9d --- /dev/null +++ b/option/src/app/java_micronaut/openapi_spec.yaml @@ -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 diff --git a/option/src/app/java_micronaut/pom.j2xml b/option/src/app/java_micronaut/pom.j2xml new file mode 100644 index 00000000..c783ef19 --- /dev/null +++ b/option/src/app/java_micronaut/pom.j2xml @@ -0,0 +1,190 @@ + + + 4.0.0 + com.example + demo + 0.1 + ${packaging} + + + io.micronaut.platform + micronaut-parent + 4.2.1 + + + jar + 17 + 17 + 4.2.1 + netty + false + com.example.aot.generated + com.example.Application + + + + + central + https://repo.maven.apache.org/maven2 + + + + +{%- if db_family !="none" %} + + {{ pomGroupId }} + {{ pomArtifactId }} + runtime + +{%- endif %} + + io.micronaut + micronaut-http-server-netty + compile + + + io.micronaut + micronaut-jackson-databind + compile + + + io.micronaut.data + micronaut-data-hibernate-jpa + compile + + + io.micronaut.data + micronaut-data-tx-hibernate + compile + + + org.yaml + snakeyaml + runtime + + + io.micronaut.sql + micronaut-hibernate-jpa + compile + + + io.micronaut.sql + micronaut-jdbc-hikari + compile + + + io.micronaut.validation + micronaut-validation + compile + + + jakarta.annotation + jakarta.annotation-api + compile + + + jakarta.validation + jakarta.validation-api + compile + + + ch.qos.logback + logback-classic + runtime + + + io.micronaut.testresources + micronaut-test-resources-client + provided + + + io.micronaut + micronaut-http-client + test + + + io.micronaut.test + micronaut-test-junit5 + test + + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + + + + io.micronaut.maven + micronaut-maven-plugin + + aot-${packaging}.properties + + + + org.apache.maven.plugins + maven-enforcer-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + + io.micronaut + micronaut-inject-java + ${micronaut.core.version} + + + io.micronaut.data + micronaut-data-processor + ${micronaut.data.version} + + + io.micronaut + micronaut-inject + + + + + io.micronaut + micronaut-graal + ${micronaut.core.version} + + + io.micronaut + micronaut-http-validation + ${micronaut.core.version} + + + io.micronaut.validation + micronaut-validation-processor + ${micronaut.validation.version} + + + io.micronaut + micronaut-inject + + + + + + -Amicronaut.processing.group=com.example + -Amicronaut.processing.module=demo + + + + + + + diff --git a/option/src/app/java_micronaut/refresh_micronaut.sh b/option/src/app/java_micronaut/refresh_micronaut.sh new file mode 100644 index 00000000..b9066bed --- /dev/null +++ b/option/src/app/java_micronaut/refresh_micronaut.sh @@ -0,0 +1,26 @@ +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/. +vi src/main/resources/application.properties + +cp orig/microprofile-config.properties.tmpl . +cp orig/src/main/resources/META-INF/persistence.xml src/main/resources/META-INF/. +cp orig/src/main/java/me/opc/mp/database/Dept* src/main/java/helidon/. +rm src/main/resources/META-INF/init_script.sql +rm src/main/resources/META-INF/microprofile-config.properties +sed -i "s/me.opc.mp.database.Dept/helidon.Dept/" src/main/resources/META-INF/persistence.xml +sed -i "s/package me.opc.mp.database/package helidon/" src/main/java/helidon/Dept* diff --git a/option/src/app/java_micronaut/src/main/java/com/example/Application.java b/option/src/app/java_micronaut/src/main/java/com/example/Application.java index e13ce431..5b4df1d0 100644 --- a/option/src/app/java_micronaut/src/main/java/com/example/Application.java +++ b/option/src/app/java_micronaut/src/main/java/com/example/Application.java @@ -3,7 +3,8 @@ import io.micronaut.runtime.Micronaut; public class Application { + public static void main(String[] args) { Micronaut.run(Application.class, args); } -} +} \ No newline at end of file diff --git a/option/src/app/java_micronaut/src/main/java/com/example/Dept.java b/option/src/app/java_micronaut/src/main/java/com/example/Dept.java index 139510f8..a27fdb60 100644 --- a/option/src/app/java_micronaut/src/main/java/com/example/Dept.java +++ b/option/src/app/java_micronaut/src/main/java/com/example/Dept.java @@ -1,6 +1,6 @@ package com.example; -import javax.persistence.*; +import jakarta.persistence.*; @Entity @Table(name = "dept") diff --git a/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java b/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java index b8470235..5806fa27 100644 --- a/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java +++ b/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java @@ -5,7 +5,7 @@ import io.micronaut.transaction.annotation.*; import io.micronaut.scheduling.TaskExecutors; import io.micronaut.scheduling.annotation.ExecuteOn; -import javax.validation.Valid; +import jakarta.validation.Valid; import java.net.URI; import java.util.List; @@ -23,7 +23,6 @@ class DeptController { @Get(uri = "dept") @Produces(MediaType.APPLICATION_JSON) - @TransactionalAdvice List dept() { return deptRepository.find(); } @@ -33,4 +32,4 @@ List dept() { String info() { return "Java - Micronaut"; } -} \ No newline at end of file +} diff --git a/option/src/app/java_micronaut/src/main/java/com/example/DeptRepository.java b/option/src/app/java_micronaut/src/main/java/com/example/DeptRepository.java index 8650b6d6..c55d55d5 100644 --- a/option/src/app/java_micronaut/src/main/java/com/example/DeptRepository.java +++ b/option/src/app/java_micronaut/src/main/java/com/example/DeptRepository.java @@ -3,7 +3,7 @@ import io.micronaut.data.annotation.Repository; import io.micronaut.data.repository.CrudRepository; -import javax.persistence.EntityManager; +import jakarta.persistence.EntityManager; import java.util.List; @Repository @@ -19,4 +19,4 @@ public List find() { return entityManager.createQuery("FROM Dept AS dept", Dept.class) .getResultList(); } -} \ No newline at end of file +} diff --git a/option/src/app/java_micronaut/src/main/resources/application.j2.yml b/option/src/app/java_micronaut/src/main/resources/application.j2.yml index f9be66ee..d89c39ad 100644 --- a/option/src/app/java_micronaut/src/main/resources/application.j2.yml +++ b/option/src/app/java_micronaut/src/main/resources/application.j2.yml @@ -7,12 +7,11 @@ datasources: url: ${JDBC_URL} username: ${DB_USER} password: ${DB_PASSWORD} + driverClassName: {{ jdbcDriverClassName }} {%- if db_family == "oracle" %} - driverClassName: oracle.jdbc.OracleDriver db-type: oracle dialect: oracle {%- elif db_family == "mysql" %} - driverClassName: com.mysql.cj.jdbc.Driver dialect: mysql {%- endif %} {%- endif %} diff --git a/option/src/app/java_micronaut/src/main/resources/application.properties.orig b/option/src/app/java_micronaut/src/main/resources/application.properties.orig new file mode 100644 index 00000000..17e20c07 --- /dev/null +++ b/option/src/app/java_micronaut/src/main/resources/application.properties.orig @@ -0,0 +1,6 @@ +#Mon Dec 11 08:44:45 UTC 2023 +datasources.default.db-type=oracle +datasources.default.dialect=ORACLE +micronaut.application.name=demo +jpa.default.properties.hibernate.hbm2ddl.auto=update +datasources.default.driver-class-name=oracle.jdbc.OracleDriver diff --git a/option/src/app/java_micronaut/src/main/resources/logback.xml b/option/src/app/java_micronaut/src/main/resources/logback.xml index 6010eb52..2d77bdab 100644 --- a/option/src/app/java_micronaut/src/main/resources/logback.xml +++ b/option/src/app/java_micronaut/src/main/resources/logback.xml @@ -1,7 +1,6 @@ - true diff --git a/option/src/app/java_micronaut/src/test/resources/application-test.properties b/option/src/app/java_micronaut/src/test/resources/application-test.properties new file mode 100644 index 00000000..c58f71ea --- /dev/null +++ b/option/src/app/java_micronaut/src/test/resources/application-test.properties @@ -0,0 +1,2 @@ +#Mon Dec 11 08:44:45 UTC 2023 +jpa.default.properties.hibernate.hbm2ddl.auto=create-drop diff --git a/option/src/app/java_micronaut3/.gitignore b/option/src/app/java_micronaut3/.gitignore new file mode 100644 index 00000000..5a03bc30 --- /dev/null +++ b/option/src/app/java_micronaut3/.gitignore @@ -0,0 +1,15 @@ +Thumbs.db +.DS_Store +.gradle +build/ +target/ +out/ +.micronaut/ +.idea +*.iml +*.ipr +*.iws +.project +.settings +.classpath +.factorypath diff --git a/option/src/app/java_micronaut/Dockerfile b/option/src/app/java_micronaut3/Dockerfile similarity index 100% rename from option/src/app/java_micronaut/Dockerfile rename to option/src/app/java_micronaut3/Dockerfile diff --git a/option/src/app/java_micronaut/Dockerfile.native b/option/src/app/java_micronaut3/Dockerfile.native similarity index 100% rename from option/src/app/java_micronaut/Dockerfile.native rename to option/src/app/java_micronaut3/Dockerfile.native diff --git a/option/src/app/java_micronaut3/README.md b/option/src/app/java_micronaut3/README.md new file mode 100644 index 00000000..5a32f049 --- /dev/null +++ b/option/src/app/java_micronaut3/README.md @@ -0,0 +1,18 @@ +## Micronaut 3.7.4 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) +- [Micronaut Guides](https://guides.micronaut.io/index.html) +--- + +## Feature http-client documentation + +- [Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient) + + +## Feature jdbc-hikari documentation + +- [Micronaut Hikari JDBC Connection Pool documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#jdbc) + + diff --git a/option/src/app/java_micronaut3/app.yaml b/option/src/app/java_micronaut3/app.yaml new file mode 100644 index 00000000..2350d3c3 --- /dev/null +++ b/option/src/app/java_micronaut3/app.yaml @@ -0,0 +1,45 @@ +apiVersion: v1 +kind: Pod +metadata: + name: ##PREFIX##-app + labels: + app: ##PREFIX##-app +spec: + containers: + - name: ##PREFIX##-app + image: ##DOCKER_PREFIX##/##PREFIX##-app + ports: + - containerPort: 8080 + name: app-port + env: + - name: JDBC_URL + valueFrom: + secretKeyRef: + name: ##PREFIX##-db-secret + key: jdbc_url + - name: DB_USER + valueFrom: + secretKeyRef: + name: ##PREFIX##-db-secret + key: db_user + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: ##PREFIX##-db-secret + key: db_password + imagePullSecrets: + - name: ocirsecret +--- +apiVersion: v1 +kind: Service +metadata: + name: ##PREFIX##-app-service +spec: + selector: + app: ##PREFIX##-app + ports: + - name: http-service-port + protocol: TCP + port: 80 + targetPort: app-port +--- \ No newline at end of file diff --git a/option/src/app/java_micronaut3/build_app.sh b/option/src/app/java_micronaut3/build_app.sh new file mode 100755 index 00000000..9294c56b --- /dev/null +++ b/option/src/app/java_micronaut3/build_app.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# Build_app.sh +# +# Compute: +# - build the code +# - create a $ROOT/target/compute/$APP_DIR directory with the compiled files +# - and a start.sh to start the program +# Docker: +# - build the image +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +. $SCRIPT_DIR/../../env.sh -no-auto +. $BIN_DIR/build_common.sh +java_build_common + +if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then + mvn package -Dpackaging=native-image +else + mvn package +fi +exit_on_error + +if is_deploy_compute; then + cp start.sh install.sh target/. + + mkdir -p ../../target/compute/$APP_DIR + cp -r target/* ../../target/compute/$APP_DIR/. + # Replace the user and password in the start file + replace_db_user_password_in_file ../../target/compute/$APP_DIR/start.sh +else + docker image rm ${TF_VAR_prefix}-app:latest + if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then + docker build -f Dockerfile.native -t ${TF_VAR_prefix}-app:latest . + else + docker build -t ${TF_VAR_prefix}-app:latest . + fi + exit_on_error +fi diff --git a/option/src/app/java_micronaut3/micronaut-cli.yml b/option/src/app/java_micronaut3/micronaut-cli.yml new file mode 100644 index 00000000..6d8785b5 --- /dev/null +++ b/option/src/app/java_micronaut3/micronaut-cli.yml @@ -0,0 +1,6 @@ +applicationType: default +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] diff --git a/option/src/app/java_micronaut/pom.j2.xml b/option/src/app/java_micronaut3/pom.j2.xml similarity index 100% rename from option/src/app/java_micronaut/pom.j2.xml rename to option/src/app/java_micronaut3/pom.j2.xml diff --git a/option/src/app/java_micronaut3/refresh_micronaut.sh b/option/src/app/java_micronaut3/refresh_micronaut.sh new file mode 100644 index 00000000..7f124cbe --- /dev/null +++ b/option/src/app/java_micronaut3/refresh_micronaut.sh @@ -0,0 +1,23 @@ +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' --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/src/main/resources/META-INF/persistence.xml src/main/resources/META-INF/. +cp orig/src/main/java/me/opc/mp/database/Dept* src/main/java/helidon/. +rm src/main/resources/META-INF/init_script.sql +rm src/main/resources/META-INF/microprofile-config.properties +sed -i "s/me.opc.mp.database.Dept/helidon.Dept/" src/main/resources/META-INF/persistence.xml +sed -i "s/package me.opc.mp.database/package helidon/" src/main/java/helidon/Dept* diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/Application.java b/option/src/app/java_micronaut3/src/main/java/com/example/Application.java new file mode 100644 index 00000000..e13ce431 --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/java/com/example/Application.java @@ -0,0 +1,9 @@ +package com.example; + +import io.micronaut.runtime.Micronaut; + +public class Application { + public static void main(String[] args) { + Micronaut.run(Application.class, args); + } +} diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java b/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java new file mode 100644 index 00000000..139510f8 --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java @@ -0,0 +1,55 @@ +package com.example; + +import javax.persistence.*; + +@Entity +@Table(name = "dept") +public class Dept { + + @Id + @Column(name = "deptno", nullable = false, updatable = false) + private int deptno; + + @Basic(optional = false) + @Column(name = "dname") + private String dname; + + @Basic(optional = false) + @Column(name = "loc") + private String loc; + + public Dept() { + } + + public Dept( int deptno, String dname, String loc) { + this.deptno = deptno; + this.dname = dname; + this.loc = loc; + } + + public int getDeptno() { + return deptno; + } + + public void setDeptno(int deptno) { + this.deptno = deptno; + } + + public String getDname() { + return dname; + } + + public void setDname(String dname) { + this.dname = dname; + } + + public String getLoc() { + return loc; + } + + public void setLoc(String loc) { + this.loc = loc; + } +} + + diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java b/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java new file mode 100644 index 00000000..b8470235 --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java @@ -0,0 +1,36 @@ +package com.example; + +import io.micronaut.http.*; +import io.micronaut.http.annotation.*; +import io.micronaut.transaction.annotation.*; +import io.micronaut.scheduling.TaskExecutors; +import io.micronaut.scheduling.annotation.ExecuteOn; +import javax.validation.Valid; +import java.net.URI; +import java.util.List; + +import jakarta.inject.Inject; +import static io.micronaut.http.HttpHeaders.LOCATION; + +@ExecuteOn(TaskExecutors.IO) +@Controller("/") +class DeptController { + @Inject + DeptRepository deptRepository; + + DeptController() { + } + + @Get(uri = "dept") + @Produces(MediaType.APPLICATION_JSON) + @TransactionalAdvice + List dept() { + return deptRepository.find(); + } + + @Get(uri = "info") + @Produces(MediaType.TEXT_PLAIN) + String info() { + return "Java - Micronaut"; + } +} \ No newline at end of file diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java b/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java new file mode 100644 index 00000000..8650b6d6 --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java @@ -0,0 +1,22 @@ +package com.example; + +import io.micronaut.data.annotation.Repository; +import io.micronaut.data.repository.CrudRepository; + +import javax.persistence.EntityManager; +import java.util.List; + +@Repository +public abstract class DeptRepository implements CrudRepository { + + private final EntityManager entityManager; + + public DeptRepository(EntityManager entityManager) { + this.entityManager = entityManager; + } + + public List find() { + return entityManager.createQuery("FROM Dept AS dept", Dept.class) + .getResultList(); + } +} \ No newline at end of file diff --git a/option/src/app/java_micronaut3/src/main/resources/application.j2.yml b/option/src/app/java_micronaut3/src/main/resources/application.j2.yml new file mode 100644 index 00000000..f9be66ee --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/resources/application.j2.yml @@ -0,0 +1,26 @@ +micronaut: + application: + name: demo +{%- if db_family !="none" %} +datasources: + default: + url: ${JDBC_URL} + username: ${DB_USER} + password: ${DB_PASSWORD} + {%- if db_family == "oracle" %} + driverClassName: oracle.jdbc.OracleDriver + db-type: oracle + dialect: oracle + {%- elif db_family == "mysql" %} + driverClassName: com.mysql.cj.jdbc.Driver + dialect: mysql + {%- endif %} +{%- endif %} +netty: + default: + allocator: + max-order: 3 +jpa: + default: + entity-scan: + packages: 'com.example' diff --git a/option/src/app/java_micronaut/src/main/resources/application_orig.yml b/option/src/app/java_micronaut3/src/main/resources/application_orig.yml similarity index 100% rename from option/src/app/java_micronaut/src/main/resources/application_orig.yml rename to option/src/app/java_micronaut3/src/main/resources/application_orig.yml diff --git a/option/src/app/java_micronaut3/src/main/resources/logback.xml b/option/src/app/java_micronaut3/src/main/resources/logback.xml new file mode 100644 index 00000000..6010eb52 --- /dev/null +++ b/option/src/app/java_micronaut3/src/main/resources/logback.xml @@ -0,0 +1,15 @@ + + + + true + + + %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n + + + + + + + diff --git a/option/src/app/java_micronaut3/start.sh b/option/src/app/java_micronaut3/start.sh new file mode 100755 index 00000000..19a32c7a --- /dev/null +++ b/option/src/app/java_micronaut3/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +cd $SCRIPT_DIR + +export DB_USER=##DB_USER## +export DB_PASSWORD=##DB_PASSWORD## +export JDBC_URL="##JDBC_URL##" +export TF_VAR_java_vm=##TF_VAR_java_vm## + +if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then + ./demo > app.log 2>&1 +else + java -jar demo-0.1.jar > app.log 2>&1 +fi \ No newline at end of file From bd0e12718e32ec4f83d3a8137c6052758133581b Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 12:15:14 +0100 Subject: [PATCH 08/13] v1.6 --- option/src/app/java_micronaut/Dockerfile | 4 ++++ option/src/app/java_micronaut/Dockerfile.native | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 option/src/app/java_micronaut/Dockerfile create mode 100644 option/src/app/java_micronaut/Dockerfile.native diff --git a/option/src/app/java_micronaut/Dockerfile b/option/src/app/java_micronaut/Dockerfile new file mode 100644 index 00000000..2c67c179 --- /dev/null +++ b/option/src/app/java_micronaut/Dockerfile @@ -0,0 +1,4 @@ +FROM ##DOCKER_IMAGE## +COPY target/demo-0.1.jar /app/app.jar +WORKDIR /app +ENTRYPOINT ["java","-jar","app.jar"] \ No newline at end of file diff --git a/option/src/app/java_micronaut/Dockerfile.native b/option/src/app/java_micronaut/Dockerfile.native new file mode 100644 index 00000000..f26b4f44 --- /dev/null +++ b/option/src/app/java_micronaut/Dockerfile.native @@ -0,0 +1,4 @@ +FROM oraclelinux:9-slim +COPY target/demo /app/app +WORKDIR /app +ENTRYPOINT ["./app"] \ No newline at end of file From 82bbeefb04ed8c58eb9aeefb07e93693e7797906 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 12:44:30 +0100 Subject: [PATCH 09/13] v1.6 --- .../java_micronaut/src/main/java/com/example/DeptController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java b/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java index 5806fa27..b084f4d6 100644 --- a/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java +++ b/option/src/app/java_micronaut/src/main/java/com/example/DeptController.java @@ -23,6 +23,7 @@ class DeptController { @Get(uri = "dept") @Produces(MediaType.APPLICATION_JSON) + @Transactional List dept() { return deptRepository.find(); } From b4edaf4890eb1b22b7b91fb9b2c1f5178a02960d Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 13:35:33 +0100 Subject: [PATCH 10/13] v1.6 --- option/src/app/java_micronaut/{pom.j2xml => pom.j2.xml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename option/src/app/java_micronaut/{pom.j2xml => pom.j2.xml} (100%) diff --git a/option/src/app/java_micronaut/pom.j2xml b/option/src/app/java_micronaut/pom.j2.xml similarity index 100% rename from option/src/app/java_micronaut/pom.j2xml rename to option/src/app/java_micronaut/pom.j2.xml From 2dbf7940b88e5fb76def4a46fbc83ec2c039eae1 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 15:34:05 +0100 Subject: [PATCH 11/13] v1.6 --- .../{refresh_sample.sh => helidon_refresh.sh} | 0 .../{refresh_micronaut.sh => micronaut_refresh.sh} | 12 ++++-------- .../src/main/java/com/example/DeptController.java | 2 +- py_oci_starter.py | 4 +++- 4 files changed, 8 insertions(+), 10 deletions(-) rename option/src/app/java_helidon4/{refresh_sample.sh => helidon_refresh.sh} (100%) rename option/src/app/java_micronaut/{refresh_micronaut.sh => micronaut_refresh.sh} (56%) diff --git a/option/src/app/java_helidon4/refresh_sample.sh b/option/src/app/java_helidon4/helidon_refresh.sh similarity index 100% rename from option/src/app/java_helidon4/refresh_sample.sh rename to option/src/app/java_helidon4/helidon_refresh.sh diff --git a/option/src/app/java_micronaut/refresh_micronaut.sh b/option/src/app/java_micronaut/micronaut_refresh.sh similarity index 56% rename from option/src/app/java_micronaut/refresh_micronaut.sh rename to option/src/app/java_micronaut/micronaut_refresh.sh index b9066bed..465dc10e 100644 --- a/option/src/app/java_micronaut/refresh_micronaut.sh +++ b/option/src/app/java_micronaut/micronaut_refresh.sh @@ -15,12 +15,8 @@ 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/. -vi src/main/resources/application.properties - cp orig/microprofile-config.properties.tmpl . -cp orig/src/main/resources/META-INF/persistence.xml src/main/resources/META-INF/. -cp orig/src/main/java/me/opc/mp/database/Dept* src/main/java/helidon/. -rm src/main/resources/META-INF/init_script.sql -rm src/main/resources/META-INF/microprofile-config.properties -sed -i "s/me.opc.mp.database.Dept/helidon.Dept/" src/main/resources/META-INF/persistence.xml -sed -i "s/package me.opc.mp.database/package helidon/" src/main/java/helidon/Dept* +cp orig/Docker* . +cp orig/src/main/resources/application.j2.yml src/main/resources/. +rm src/main/resources/application.properties + diff --git a/option/src/app/java_micronaut_none/src/main/java/com/example/DeptController.java b/option/src/app/java_micronaut_none/src/main/java/com/example/DeptController.java index 2a7b7391..deebf2a3 100644 --- a/option/src/app/java_micronaut_none/src/main/java/com/example/DeptController.java +++ b/option/src/app/java_micronaut_none/src/main/java/com/example/DeptController.java @@ -5,7 +5,7 @@ import io.micronaut.transaction.annotation.*; import io.micronaut.scheduling.TaskExecutors; import io.micronaut.scheduling.annotation.ExecuteOn; -import javax.validation.Valid; +import jakarta.validation.Valid; import java.net.URI; import java.util.List; import java.util.ArrayList; diff --git a/py_oci_starter.py b/py_oci_starter.py index 34f0ca09..6186dfe6 100755 --- a/py_oci_starter.py +++ b/py_oci_starter.py @@ -1029,7 +1029,9 @@ def jinja2_replace_template(): with open(output_file_path, mode="w", encoding="utf-8") as output_file: output_file.write(content) print(f"Wrote {output_file}") - os.remove(os.path.join(subdir, filename)) + os.remove(os.path.join(subdir, filename)) + if filename.endswith('_refresh.sh'): + os.remove(os.path.join(subdir, filename)) #---------------------------------------------------------------------------- From 4508f791a18701e0e79fa56d8edd10eca1090bf8 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 15:34:33 +0100 Subject: [PATCH 12/13] v1.6 --- option/src/app/forms/domainconfig.sh | 0 option/src/app/java_helidon4/helidon_refresh.sh | 0 option/src/app/java_micronaut/micronaut_refresh.sh | 0 option/src/app/java_micronaut3/refresh_micronaut.sh | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 option/src/app/forms/domainconfig.sh mode change 100644 => 100755 option/src/app/java_helidon4/helidon_refresh.sh mode change 100644 => 100755 option/src/app/java_micronaut/micronaut_refresh.sh mode change 100644 => 100755 option/src/app/java_micronaut3/refresh_micronaut.sh diff --git a/option/src/app/forms/domainconfig.sh b/option/src/app/forms/domainconfig.sh old mode 100644 new mode 100755 diff --git a/option/src/app/java_helidon4/helidon_refresh.sh b/option/src/app/java_helidon4/helidon_refresh.sh old mode 100644 new mode 100755 diff --git a/option/src/app/java_micronaut/micronaut_refresh.sh b/option/src/app/java_micronaut/micronaut_refresh.sh old mode 100644 new mode 100755 diff --git a/option/src/app/java_micronaut3/refresh_micronaut.sh b/option/src/app/java_micronaut3/refresh_micronaut.sh old mode 100644 new mode 100755 From 51ecf1df3776d812ffff474943513e94a48179f0 Mon Sep 17 00:00:00 2001 From: Marc Gueury Date: Mon, 11 Dec 2023 15:52:57 +0100 Subject: [PATCH 13/13] v1.6 --- option/src/app/java_micronaut3/.gitignore | 15 -- option/src/app/java_micronaut3/Dockerfile | 4 - .../src/app/java_micronaut3/Dockerfile.native | 4 - option/src/app/java_micronaut3/README.md | 18 -- option/src/app/java_micronaut3/app.yaml | 45 ----- option/src/app/java_micronaut3/build_app.sh | 37 ---- .../src/app/java_micronaut3/micronaut-cli.yml | 6 - option/src/app/java_micronaut3/pom.j2.xml | 171 ------------------ .../app/java_micronaut3/refresh_micronaut.sh | 23 --- .../main/java/com/example/Application.java | 9 - .../src/main/java/com/example/Dept.java | 55 ------ .../main/java/com/example/DeptController.java | 36 ---- .../main/java/com/example/DeptRepository.java | 22 --- .../src/main/resources/application.j2.yml | 26 --- .../src/main/resources/application_orig.yml | 19 -- .../src/main/resources/logback.xml | 15 -- option/src/app/java_micronaut3/start.sh | 14 -- 17 files changed, 519 deletions(-) delete mode 100644 option/src/app/java_micronaut3/.gitignore delete mode 100644 option/src/app/java_micronaut3/Dockerfile delete mode 100644 option/src/app/java_micronaut3/Dockerfile.native delete mode 100644 option/src/app/java_micronaut3/README.md delete mode 100644 option/src/app/java_micronaut3/app.yaml delete mode 100755 option/src/app/java_micronaut3/build_app.sh delete mode 100644 option/src/app/java_micronaut3/micronaut-cli.yml delete mode 100644 option/src/app/java_micronaut3/pom.j2.xml delete mode 100755 option/src/app/java_micronaut3/refresh_micronaut.sh delete mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/Application.java delete mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/Dept.java delete mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java delete mode 100644 option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java delete mode 100644 option/src/app/java_micronaut3/src/main/resources/application.j2.yml delete mode 100644 option/src/app/java_micronaut3/src/main/resources/application_orig.yml delete mode 100644 option/src/app/java_micronaut3/src/main/resources/logback.xml delete mode 100755 option/src/app/java_micronaut3/start.sh diff --git a/option/src/app/java_micronaut3/.gitignore b/option/src/app/java_micronaut3/.gitignore deleted file mode 100644 index 5a03bc30..00000000 --- a/option/src/app/java_micronaut3/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -Thumbs.db -.DS_Store -.gradle -build/ -target/ -out/ -.micronaut/ -.idea -*.iml -*.ipr -*.iws -.project -.settings -.classpath -.factorypath diff --git a/option/src/app/java_micronaut3/Dockerfile b/option/src/app/java_micronaut3/Dockerfile deleted file mode 100644 index 2c67c179..00000000 --- a/option/src/app/java_micronaut3/Dockerfile +++ /dev/null @@ -1,4 +0,0 @@ -FROM ##DOCKER_IMAGE## -COPY target/demo-0.1.jar /app/app.jar -WORKDIR /app -ENTRYPOINT ["java","-jar","app.jar"] \ No newline at end of file diff --git a/option/src/app/java_micronaut3/Dockerfile.native b/option/src/app/java_micronaut3/Dockerfile.native deleted file mode 100644 index f26b4f44..00000000 --- a/option/src/app/java_micronaut3/Dockerfile.native +++ /dev/null @@ -1,4 +0,0 @@ -FROM oraclelinux:9-slim -COPY target/demo /app/app -WORKDIR /app -ENTRYPOINT ["./app"] \ No newline at end of file diff --git a/option/src/app/java_micronaut3/README.md b/option/src/app/java_micronaut3/README.md deleted file mode 100644 index 5a32f049..00000000 --- a/option/src/app/java_micronaut3/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## Micronaut 3.7.4 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) -- [Micronaut Guides](https://guides.micronaut.io/index.html) ---- - -## Feature http-client documentation - -- [Micronaut HTTP Client documentation](https://docs.micronaut.io/latest/guide/index.html#httpClient) - - -## Feature jdbc-hikari documentation - -- [Micronaut Hikari JDBC Connection Pool documentation](https://micronaut-projects.github.io/micronaut-sql/latest/guide/index.html#jdbc) - - diff --git a/option/src/app/java_micronaut3/app.yaml b/option/src/app/java_micronaut3/app.yaml deleted file mode 100644 index 2350d3c3..00000000 --- a/option/src/app/java_micronaut3/app.yaml +++ /dev/null @@ -1,45 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: ##PREFIX##-app - labels: - app: ##PREFIX##-app -spec: - containers: - - name: ##PREFIX##-app - image: ##DOCKER_PREFIX##/##PREFIX##-app - ports: - - containerPort: 8080 - name: app-port - env: - - name: JDBC_URL - valueFrom: - secretKeyRef: - name: ##PREFIX##-db-secret - key: jdbc_url - - name: DB_USER - valueFrom: - secretKeyRef: - name: ##PREFIX##-db-secret - key: db_user - - name: DB_PASSWORD - valueFrom: - secretKeyRef: - name: ##PREFIX##-db-secret - key: db_password - imagePullSecrets: - - name: ocirsecret ---- -apiVersion: v1 -kind: Service -metadata: - name: ##PREFIX##-app-service -spec: - selector: - app: ##PREFIX##-app - ports: - - name: http-service-port - protocol: TCP - port: 80 - targetPort: app-port ---- \ No newline at end of file diff --git a/option/src/app/java_micronaut3/build_app.sh b/option/src/app/java_micronaut3/build_app.sh deleted file mode 100755 index 9294c56b..00000000 --- a/option/src/app/java_micronaut3/build_app.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Build_app.sh -# -# Compute: -# - build the code -# - create a $ROOT/target/compute/$APP_DIR directory with the compiled files -# - and a start.sh to start the program -# Docker: -# - build the image -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -. $SCRIPT_DIR/../../env.sh -no-auto -. $BIN_DIR/build_common.sh -java_build_common - -if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then - mvn package -Dpackaging=native-image -else - mvn package -fi -exit_on_error - -if is_deploy_compute; then - cp start.sh install.sh target/. - - mkdir -p ../../target/compute/$APP_DIR - cp -r target/* ../../target/compute/$APP_DIR/. - # Replace the user and password in the start file - replace_db_user_password_in_file ../../target/compute/$APP_DIR/start.sh -else - docker image rm ${TF_VAR_prefix}-app:latest - if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then - docker build -f Dockerfile.native -t ${TF_VAR_prefix}-app:latest . - else - docker build -t ${TF_VAR_prefix}-app:latest . - fi - exit_on_error -fi diff --git a/option/src/app/java_micronaut3/micronaut-cli.yml b/option/src/app/java_micronaut3/micronaut-cli.yml deleted file mode 100644 index 6d8785b5..00000000 --- a/option/src/app/java_micronaut3/micronaut-cli.yml +++ /dev/null @@ -1,6 +0,0 @@ -applicationType: default -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] diff --git a/option/src/app/java_micronaut3/pom.j2.xml b/option/src/app/java_micronaut3/pom.j2.xml deleted file mode 100644 index 916ed384..00000000 --- a/option/src/app/java_micronaut3/pom.j2.xml +++ /dev/null @@ -1,171 +0,0 @@ - - - 4.0.0 - com.example - demo - 0.1 - ${packaging} - - - io.micronaut - micronaut-parent - 3.7.4 - - - - jar - 11 - 11 - 3.7.4 - netty - 3.8.1 - com.example.Application - - - - - central - https://repo.maven.apache.org/maven2 - - - - -{%- if db_family !="none" %} - - {{ pomGroupId }} - {{ pomArtifactId }} - runtime - -{%- endif %} - - io.micronaut - micronaut-inject - compile - - - io.micronaut - micronaut-validation - compile - - - io.micronaut - micronaut-http-client - compile - - - io.micronaut - micronaut-http-server-netty - compile - - - io.micronaut - micronaut-jackson-databind - compile - - - io.micronaut.data - micronaut-data-hibernate-jpa - compile - - - io.micronaut.sql - micronaut-jdbc-hikari - compile - - - jakarta.annotation - jakarta.annotation-api - compile - - - ch.qos.logback - logback-classic - runtime - - - - io.micronaut.test - micronaut-test-junit5 - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - io.micronaut - micronaut-runtime - - - io.micronaut - micronaut-jackson-databind - - - compile - - - - - - - io.micronaut.build - micronaut-maven-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - - - io.micronaut - micronaut-inject-java - ${micronaut.version} - - - io.micronaut.data - micronaut-data-processor - ${micronaut.data.version} - - - io.micronaut - micronaut-graal - ${micronaut.version} - - - io.micronaut - micronaut-http-validation - ${micronaut.version} - - - io.micronaut - micronaut-validation - ${micronaut.version} - - - - -Amicronaut.processing.group=com.example - -Amicronaut.processing.module=demo - - - - - - - diff --git a/option/src/app/java_micronaut3/refresh_micronaut.sh b/option/src/app/java_micronaut3/refresh_micronaut.sh deleted file mode 100755 index 7f124cbe..00000000 --- a/option/src/app/java_micronaut3/refresh_micronaut.sh +++ /dev/null @@ -1,23 +0,0 @@ -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' --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/src/main/resources/META-INF/persistence.xml src/main/resources/META-INF/. -cp orig/src/main/java/me/opc/mp/database/Dept* src/main/java/helidon/. -rm src/main/resources/META-INF/init_script.sql -rm src/main/resources/META-INF/microprofile-config.properties -sed -i "s/me.opc.mp.database.Dept/helidon.Dept/" src/main/resources/META-INF/persistence.xml -sed -i "s/package me.opc.mp.database/package helidon/" src/main/java/helidon/Dept* diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/Application.java b/option/src/app/java_micronaut3/src/main/java/com/example/Application.java deleted file mode 100644 index e13ce431..00000000 --- a/option/src/app/java_micronaut3/src/main/java/com/example/Application.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example; - -import io.micronaut.runtime.Micronaut; - -public class Application { - public static void main(String[] args) { - Micronaut.run(Application.class, args); - } -} diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java b/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java deleted file mode 100644 index 139510f8..00000000 --- a/option/src/app/java_micronaut3/src/main/java/com/example/Dept.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example; - -import javax.persistence.*; - -@Entity -@Table(name = "dept") -public class Dept { - - @Id - @Column(name = "deptno", nullable = false, updatable = false) - private int deptno; - - @Basic(optional = false) - @Column(name = "dname") - private String dname; - - @Basic(optional = false) - @Column(name = "loc") - private String loc; - - public Dept() { - } - - public Dept( int deptno, String dname, String loc) { - this.deptno = deptno; - this.dname = dname; - this.loc = loc; - } - - public int getDeptno() { - return deptno; - } - - public void setDeptno(int deptno) { - this.deptno = deptno; - } - - public String getDname() { - return dname; - } - - public void setDname(String dname) { - this.dname = dname; - } - - public String getLoc() { - return loc; - } - - public void setLoc(String loc) { - this.loc = loc; - } -} - - diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java b/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java deleted file mode 100644 index b8470235..00000000 --- a/option/src/app/java_micronaut3/src/main/java/com/example/DeptController.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.example; - -import io.micronaut.http.*; -import io.micronaut.http.annotation.*; -import io.micronaut.transaction.annotation.*; -import io.micronaut.scheduling.TaskExecutors; -import io.micronaut.scheduling.annotation.ExecuteOn; -import javax.validation.Valid; -import java.net.URI; -import java.util.List; - -import jakarta.inject.Inject; -import static io.micronaut.http.HttpHeaders.LOCATION; - -@ExecuteOn(TaskExecutors.IO) -@Controller("/") -class DeptController { - @Inject - DeptRepository deptRepository; - - DeptController() { - } - - @Get(uri = "dept") - @Produces(MediaType.APPLICATION_JSON) - @TransactionalAdvice - List dept() { - return deptRepository.find(); - } - - @Get(uri = "info") - @Produces(MediaType.TEXT_PLAIN) - String info() { - return "Java - Micronaut"; - } -} \ No newline at end of file diff --git a/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java b/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java deleted file mode 100644 index 8650b6d6..00000000 --- a/option/src/app/java_micronaut3/src/main/java/com/example/DeptRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example; - -import io.micronaut.data.annotation.Repository; -import io.micronaut.data.repository.CrudRepository; - -import javax.persistence.EntityManager; -import java.util.List; - -@Repository -public abstract class DeptRepository implements CrudRepository { - - private final EntityManager entityManager; - - public DeptRepository(EntityManager entityManager) { - this.entityManager = entityManager; - } - - public List find() { - return entityManager.createQuery("FROM Dept AS dept", Dept.class) - .getResultList(); - } -} \ No newline at end of file diff --git a/option/src/app/java_micronaut3/src/main/resources/application.j2.yml b/option/src/app/java_micronaut3/src/main/resources/application.j2.yml deleted file mode 100644 index f9be66ee..00000000 --- a/option/src/app/java_micronaut3/src/main/resources/application.j2.yml +++ /dev/null @@ -1,26 +0,0 @@ -micronaut: - application: - name: demo -{%- if db_family !="none" %} -datasources: - default: - url: ${JDBC_URL} - username: ${DB_USER} - password: ${DB_PASSWORD} - {%- if db_family == "oracle" %} - driverClassName: oracle.jdbc.OracleDriver - db-type: oracle - dialect: oracle - {%- elif db_family == "mysql" %} - driverClassName: com.mysql.cj.jdbc.Driver - dialect: mysql - {%- endif %} -{%- endif %} -netty: - default: - allocator: - max-order: 3 -jpa: - default: - entity-scan: - packages: 'com.example' diff --git a/option/src/app/java_micronaut3/src/main/resources/application_orig.yml b/option/src/app/java_micronaut3/src/main/resources/application_orig.yml deleted file mode 100644 index 38d83f37..00000000 --- a/option/src/app/java_micronaut3/src/main/resources/application_orig.yml +++ /dev/null @@ -1,19 +0,0 @@ -micronaut: - application: - name: demo -datasources: - default: - url: ${JDBC_URL} - username: ${DB_USER} - password: ${DB_PASSWORD} - driverClassName: oracle.jdbc.OracleDriver - db-type: oracle - dialect: oracle -netty: - default: - allocator: - max-order: 3 -jpa: - default: - entity-scan: - packages: 'com.example' diff --git a/option/src/app/java_micronaut3/src/main/resources/logback.xml b/option/src/app/java_micronaut3/src/main/resources/logback.xml deleted file mode 100644 index 6010eb52..00000000 --- a/option/src/app/java_micronaut3/src/main/resources/logback.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - true - - - %cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n - - - - - - - diff --git a/option/src/app/java_micronaut3/start.sh b/option/src/app/java_micronaut3/start.sh deleted file mode 100755 index 19a32c7a..00000000 --- a/option/src/app/java_micronaut3/start.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -cd $SCRIPT_DIR - -export DB_USER=##DB_USER## -export DB_PASSWORD=##DB_PASSWORD## -export JDBC_URL="##JDBC_URL##" -export TF_VAR_java_vm=##TF_VAR_java_vm## - -if [ "$TF_VAR_java_vm" == "graalvm-native" ]; then - ./demo > app.log 2>&1 -else - java -jar demo-0.1.jar > app.log 2>&1 -fi \ No newline at end of file