diff --git a/basis/bin/build_all.sh b/basis/bin/build_all.sh index 1b726dad..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 [ "$TF_VAR_deploy_strategy" == "compute" ]; then +if is_deploy_compute; then mkdir -p target/compute cp src/compute/* target/compute/. fi @@ -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/basis/bin/shared_bash_function.sh b/basis/bin/shared_bash_function.sh index 62d6bb26..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 [ "$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..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 [ "$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..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 [ "$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/forms/domainconfig.sh b/option/src/app/forms/domainconfig.sh old mode 100644 new mode 100755 diff --git a/option/src/app/java_helidon/build_app.sh b/option/src/app/java_helidon/build_app.sh index cb65b399..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 [ "$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..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 [ "$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_helidon4/refresh_sample.sh b/option/src/app/java_helidon4/helidon_refresh.sh old mode 100644 new mode 100755 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/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/build_app.sh b/option/src/app/java_micronaut/build_app.sh index 08131dc6..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 [ "$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_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/micronaut_refresh.sh b/option/src/app/java_micronaut/micronaut_refresh.sh new file mode 100755 index 00000000..465dc10e --- /dev/null +++ b/option/src/app/java_micronaut/micronaut_refresh.sh @@ -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 + 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.j2.xml b/option/src/app/java_micronaut/pom.j2.xml index 916ed384..c783ef19 100644 --- a/option/src/app/java_micronaut/pom.j2.xml +++ b/option/src/app/java_micronaut/pom.j2.xml @@ -8,18 +8,18 @@ ${packaging} - io.micronaut + io.micronaut.platform micronaut-parent - 3.7.4 + 4.2.1 - jar - 11 - 11 - 3.7.4 + 17 + 17 + 4.2.1 netty - 3.8.1 + false + com.example.aot.generated com.example.Application @@ -37,35 +37,35 @@ {{ pomArtifactId }} runtime -{%- endif %} +{%- endif %} io.micronaut - micronaut-inject + micronaut-http-server-netty compile io.micronaut - micronaut-validation + micronaut-jackson-databind compile - io.micronaut - micronaut-http-client + io.micronaut.data + micronaut-data-hibernate-jpa compile - io.micronaut - micronaut-http-server-netty + io.micronaut.data + micronaut-data-tx-hibernate compile - io.micronaut - micronaut-jackson-databind - compile + org.yaml + snakeyaml + runtime - io.micronaut.data - micronaut-data-hibernate-jpa + io.micronaut.sql + micronaut-hibernate-jpa compile @@ -73,23 +73,36 @@ 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.test micronaut-test-junit5 @@ -105,26 +118,20 @@ junit-jupiter-engine test - - io.micronaut - micronaut-runtime - - - io.micronaut - micronaut-jackson-databind - - - compile - - - io.micronaut.build + io.micronaut.maven micronaut-maven-plugin + + aot-${packaging}.properties + + + + org.apache.maven.plugins + maven-enforcer-plugin - org.apache.maven.plugins maven-compiler-plugin @@ -136,27 +143,39 @@ io.micronaut micronaut-inject-java - ${micronaut.version} + ${micronaut.core.version} io.micronaut.data micronaut-data-processor ${micronaut.data.version} + + + io.micronaut + micronaut-inject + + io.micronaut micronaut-graal - ${micronaut.version} + ${micronaut.core.version} io.micronaut micronaut-http-validation - ${micronaut.version} + ${micronaut.core.version} - io.micronaut - micronaut-validation - ${micronaut.version} + io.micronaut.validation + micronaut-validation-processor + ${micronaut.validation.version} + + + io.micronaut + micronaut-inject + + 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..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 @@ -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,7 @@ class DeptController { @Get(uri = "dept") @Produces(MediaType.APPLICATION_JSON) - @TransactionalAdvice + @Transactional List dept() { return deptRepository.find(); } @@ -33,4 +33,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/application_orig.yml b/option/src/app/java_micronaut/src/main/resources/application_orig.yml deleted file mode 100644 index 38d83f37..00000000 --- a/option/src/app/java_micronaut/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_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_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/option/src/app/java_springboot/build_app.sh b/option/src/app/java_springboot/build_app.sh index 88099ae2..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 [ "$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..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 [ "$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..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 [ "$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..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 [ "$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/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 diff --git a/option/terraform/instance_pool.tf b/option/terraform/instance_pool.tf new file mode 100644 index 00000000..5ff500ef --- /dev/null +++ b/option/terraform/instance_pool.tf @@ -0,0 +1,158 @@ +variable compute_ready { default = "" } + +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}-pool$${launchCount}" + instance_hostname_formatter = "${var.prefix}-pool$${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" { + 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 = 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" { + 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 "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 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() { diff --git a/py_oci_starter.py b/py_oci_starter.py index ede44945..6186dfe6 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: @@ -1028,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)) #----------------------------------------------------------------------------