From fddae88a0d29282e23f46ef5813ee08b88f8783d Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 09:28:45 -0300 Subject: [PATCH 01/37] Create devfile.yaml --- devfile.yaml | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 devfile.yaml diff --git a/devfile.yaml b/devfile.yaml new file mode 100644 index 00000000..7b969932 --- /dev/null +++ b/devfile.yaml @@ -0,0 +1,60 @@ +schemaVersion: 2.1.0 +metadata: + name: jhipster-online + version: 2.1.0 +components: + - name: tools + container: + image: 'quay.io/maximilianopizarro/jhipster-devspace' + mountSources: true + cpuLimit: '4' + cpuRequest: '1' + memoryLimit: '8G' + memoryRequest: '4G' + volumeMounts: + - name: m2 + path: /home/user/.m2 + - name: config + path: /home/user/.config + - name: npm + path: /home/user/.npm + endpoints: + - exposure: public + name: jhipster-online + protocol: https + targetPort: 8080 + env: + - value: '-XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xms20m -Djava.security.egd=file:/dev/./urandom -Duser.home=/home/jboss' + name: JAVA_OPTS + - value: $(JAVA_OPTS) + name: MAVEN_OPTS + - value: '/home/tooling/.sdkman/candidates/java/11.0.15-tem' + name: JAVA_HOME + - name: m2 + volume: + size: 512Mi + - name: config + volume: + size: 512Mi + - name: npm + volume: + size: 512Mi +commands: + - id: build + exec: + label: "Package the application" + component: tools + workingDir: ${PROJECTS_ROOT}/jhipster-online/app + commandLine: "mvn clean install -DskipTest" + group: + kind: build + isDefault: true + - id: run-app + exec: + label: "run-app" + component: tools + workingDir: ${PROJECT_SOURCE}/jhipster-online/app + commandLine: "./mvnw" + group: + kind: run + isDefault: true From 3299fbe2216533cb66e20777c118b8a2df2ececb Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 14:57:28 +0000 Subject: [PATCH 02/37] Try in Red Hat DevSpaces --- README.md | 34 ++++ pom.xml | 4 + src/main/kubernetes/mysql.yaml | 158 ++++++++++++++++++ src/main/resources/config/application-dev.yml | 3 + 4 files changed, 199 insertions(+) create mode 100644 src/main/kubernetes/mysql.yaml diff --git a/README.md b/README.md index 7b3e2a0a..33ea3205 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,40 @@ Then run: docker compose -f src/main/docker/app.yml up -d ``` +### Developer Sandbox using + +- Launch Red Hat Dev Spaces + +``` +Import from Git and Open Terminal +``` + +- Update application-dev.yml file, using your value + +``` +# url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline +# username: jhipster +# password: jhipster +``` + +- Run the database: + +``` +oc apply -f src/main/kubernetes/mysql.yaml +``` + +- Run the back-end: + +``` +./mvnw -Pdev +``` + +- Install and run the front-end: + +``` +yarn install && yarn start +``` + ## Deployment to Google App Engine (GAE) Flexible Environment - The project can be deployed to [GAE flexible environment](https://cloud.google.com/appengine/docs/flexible/) by simply [creating a tagged release](https://github.com/jhipster/jhipster-online/releases). diff --git a/pom.xml b/pom.xml index 64d537df..02c96261 100644 --- a/pom.xml +++ b/pom.xml @@ -187,6 +187,10 @@ mysql mysql-connector-java + + org.mariadb.jdbc + mariadb-java-client + org.ehcache ehcache diff --git a/src/main/kubernetes/mysql.yaml b/src/main/kubernetes/mysql.yaml new file mode 100644 index 00000000..9f61ad9c --- /dev/null +++ b/src/main/kubernetes/mysql.yaml @@ -0,0 +1,158 @@ +kind: Secret +apiVersion: v1 +metadata: + name: mariadb + labels: + app.openshift.io/runtime: mariadb + template: mariadb-ephemeral-template + template.openshift.io/template-instance-owner: 5141732c-e33c-4366-82db-f5775278edc6 + annotations: + template.openshift.io/expose-database_name: "{.data['database-name']}" + template.openshift.io/expose-password: "{.data['database-password']}" + template.openshift.io/expose-root_password: "{.data['database-root-password']}" + template.openshift.io/expose-username: "{.data['database-user']}" +data: + database-name: amhpcHN0ZXJvbmxpbmU= + database-password: amhpcHN0ZXI= + database-root-password: amhpcHN0ZXI= + database-user: amhpcHN0ZXI= +type: Opaque +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mariadb + labels: + app: mariadb + app.kubernetes.io/component: mariadb + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + app.kubernetes.io/part-of: mariadb + app.openshift.io/runtime: mariadb +spec: + strategy: + type: Recreate + recreateParams: + timeoutSeconds: 600 + resources: {} + activeDeadlineSeconds: 21600 + replicas: 1 + revisionHistoryLimit: 10 + test: false + selector: + matchLabels: + app: mariadb + template: + metadata: + creationTimestamp: null + labels: + app: mariadb + app.openshift.io/runtime: mariadb + deployment: mariadb + spec: + volumes: + - name: mariadb-data + persistentVolumeClaim: + claimName: mariadb-data + containers: + - resources: + limits: + memory: 512Mi + readinessProbe: + exec: + command: + - /bin/sh + - '-i' + - '-c' + - MYSQL_PWD="$MYSQL_PASSWORD" mysqladmin -u $MYSQL_USER ping + initialDelaySeconds: 5 + timeoutSeconds: 1 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 3 + terminationMessagePath: /dev/termination-log + name: mariadb + livenessProbe: + exec: + command: + - /bin/sh + - '-i' + - '-c' + - MYSQL_PWD="$MYSQL_PASSWORD" mysqladmin -u $MYSQL_USER ping + initialDelaySeconds: 30 + timeoutSeconds: 1 + periodSeconds: 10 + successThreshold: 1 + failureThreshold: 3 + env: + - name: MYSQL_USER + valueFrom: + secretKeyRef: + name: mariadb + key: database-user + - name: MYSQL_PASSWORD + valueFrom: + secretKeyRef: + name: mariadb + key: database-password + - name: MYSQL_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mariadb + key: database-root-password + - name: MYSQL_DATABASE + valueFrom: + secretKeyRef: + name: mariadb + key: database-name + ports: + - containerPort: 3306 + protocol: TCP + imagePullPolicy: IfNotPresent + volumeMounts: + - name: mariadb-data + mountPath: /var/lib/mysql/data + terminationMessagePolicy: File + image: >- + image-registry.openshift-image-registry.svc:5000/openshift/mariadb@sha256:513f7db527608c6c96b3659220ffc0397bdd30ff6617dad1790a90e14ac4f3b0 + restartPolicy: Always + terminationGracePeriodSeconds: 30 + dnsPolicy: ClusterFirst + securityContext: {} + schedulerName: default-scheduler +--- +apiVersion: v1 +kind: Service +metadata: + labels: + app: mariadb + app.kubernetes.io/component: mariadb + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + app.kubernetes.io/part-of: mariadb + name: mariadb +spec: + ports: + - name: 3306-tcp + protocol: TCP + port: 3306 + targetPort: 3306 + selector: + app: mariadb + deployment: mariadb +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mariadb-data + labels: + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + app.kubernetes.io/part-of: mariadb +spec: + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 1Gi diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index a6878a31..63a8181f 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -34,6 +34,9 @@ spring: url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true username: root password: + # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline + # username: jhipster + # password: jhipster hikari: poolName: Hikari auto-commit: false From a6bcc3d3e2f052203fe6c4a94d7a4271703807d9 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 15:06:34 +0000 Subject: [PATCH 03/37] Try in Red Hat DevSpaces --- README.md | 4 ++-- src/main/resources/config/application-dev.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 33ea3205..aa674e1c 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ Then run: docker compose -f src/main/docker/app.yml up -d ``` -### Developer Sandbox using +### Using Developer Sandbox - Launch Red Hat Dev Spaces @@ -191,7 +191,7 @@ docker compose -f src/main/docker/app.yml up -d Import from Git and Open Terminal ``` -- Update application-dev.yml file, using your value +- Update application-dev.yml file, database seccion using your value. ``` # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 63a8181f..2357a1ff 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -34,9 +34,9 @@ spring: url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true username: root password: - # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline - # username: jhipster - # password: jhipster + # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline + # username: jhipster + # password: jhipster hikari: poolName: Hikari auto-commit: false From b5a074db7d030c08a269b1e7176465319b98c5f5 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 15:07:32 +0000 Subject: [PATCH 04/37] Try in Red Hat DevSpaces --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aa674e1c..eeca6f13 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ docker compose -f src/main/docker/app.yml up -d Import from Git and Open Terminal ``` -- Update application-dev.yml file, database seccion using your value. +- Update application-dev.yml file, database seccion using your NAMESPACE value. ``` # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline From b5ee13fb59ce299f819c628be656b53035746e93 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 15:09:25 +0000 Subject: [PATCH 05/37] Try in Red Hat DevSpaces --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index eeca6f13..7b15e502 100644 --- a/README.md +++ b/README.md @@ -205,16 +205,16 @@ Import from Git and Open Terminal oc apply -f src/main/kubernetes/mysql.yaml ``` -- Run the back-end: +- Install and run the front-end: ``` -./mvnw -Pdev +yarn install && yarn start ``` -- Install and run the front-end: +- Run the back-end in other terminal: ``` -yarn install && yarn start +./mvnw -Pdev ``` ## Deployment to Google App Engine (GAE) Flexible Environment From f26cd669a2c24e70b599a3e6cfe2fb8d882bb2b2 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 17:52:36 +0000 Subject: [PATCH 06/37] devfile.yaml --- devfile.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index 7b969932..c64b66bf 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -44,7 +44,7 @@ commands: exec: label: "Package the application" component: tools - workingDir: ${PROJECTS_ROOT}/jhipster-online/app + workingDir: ${PROJECTS_ROOT}/jhipster-online commandLine: "mvn clean install -DskipTest" group: kind: build @@ -53,7 +53,7 @@ commands: exec: label: "run-app" component: tools - workingDir: ${PROJECT_SOURCE}/jhipster-online/app + workingDir: ${PROJECT_SOURCE}/jhipster-online commandLine: "./mvnw" group: kind: run From a5f0c9cec2d924cfdd1696853b8b8999bb03907f Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 18:10:08 +0000 Subject: [PATCH 07/37] devfile.yaml --- devfile.yaml | 54 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index c64b66bf..356c6923 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -2,9 +2,15 @@ schemaVersion: 2.1.0 metadata: name: jhipster-online version: 2.1.0 + description: Stack with the JHipster Online on DevSpaces + displayName: JHipster Online + icon: https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/java-maven.jpg + versions: + - version: v2.33.0 + default: true components: - name: tools - container: + container: image: 'quay.io/maximilianopizarro/jhipster-devspace' mountSources: true cpuLimit: '4' @@ -20,41 +26,63 @@ components: path: /home/user/.npm endpoints: - exposure: public - name: jhipster-online + name: backend protocol: https - targetPort: 8080 + targetPort: 8080 + - exposure: public + name: frontend + protocol: https + targetPort: 9000 env: - value: '-XX:MaxRAMPercentage=50.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xms20m -Djava.security.egd=file:/dev/./urandom -Duser.home=/home/jboss' name: JAVA_OPTS - value: $(JAVA_OPTS) name: MAVEN_OPTS - value: '/home/tooling/.sdkman/candidates/java/11.0.15-tem' - name: JAVA_HOME + name: JAVA_HOME - name: m2 volume: - size: 512Mi + size: 512Mi - name: config volume: size: 512Mi - name: npm volume: - size: 512Mi + size: 512Mi commands: - id: build exec: - label: "Package the application" - component: tools + label: 'Package the application' + component: tools workingDir: ${PROJECTS_ROOT}/jhipster-online - commandLine: "mvn clean install -DskipTest" + commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml' group: kind: build isDefault: true - - id: run-app + - id: build exec: - label: "run-app" + label: 'Package the application' + component: tools + workingDir: ${PROJECTS_ROOT}/jhipster-online + commandLine: 'yarn install' + group: + kind: build + isDefault: true + - id: run-frontend + exec: + label: 'run-frontend' component: tools workingDir: ${PROJECT_SOURCE}/jhipster-online - commandLine: "./mvnw" + commandLine: 'yarn start' + group: + kind: build + isDefault: true + - id: run-backend + exec: + label: 'run-backend' + component: tools + workingDir: ${PROJECT_SOURCE}/jhipster-online + commandLine: './mvnw' group: kind: run - isDefault: true + isDefault: true From 9db8f559b9fe0956fc7b74791222145745401f93 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 18:25:43 +0000 Subject: [PATCH 08/37] devfile.yaml --- devfile.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index 356c6923..305af333 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -52,37 +52,37 @@ components: commands: - id: build exec: - label: 'Package the application' + label: 'Mysql Instance' component: tools - workingDir: ${PROJECTS_ROOT}/jhipster-online + workingDir: ${PROJECTS_ROOT} commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml' group: kind: build isDefault: true - id: build exec: - label: 'Package the application' + label: 'Package the application with yarn' component: tools - workingDir: ${PROJECTS_ROOT}/jhipster-online + workingDir: ${PROJECTS_ROOT} commandLine: 'yarn install' group: kind: build isDefault: true - id: run-frontend exec: - label: 'run-frontend' + label: 'Run Frontend' component: tools - workingDir: ${PROJECT_SOURCE}/jhipster-online + workingDir: ${PROJECT_SOURCE} commandLine: 'yarn start' group: kind: build isDefault: true - id: run-backend exec: - label: 'run-backend' + label: 'Run Backend' component: tools - workingDir: ${PROJECT_SOURCE}/jhipster-online - commandLine: './mvnw' + workingDir: ${PROJECT_SOURCE} + commandLine: 'chmod 777 .mvnw && ./mvnw' group: kind: run isDefault: true From a8df883b76b86ea7fffa5aaa807a275acb196a43 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 18:44:33 +0000 Subject: [PATCH 09/37] devfile.yaml --- devfile.yaml | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index 305af333..473e1fe5 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -52,37 +52,19 @@ components: commands: - id: build exec: - label: 'Mysql Instance' + label: 'Package the application with yarn and create Mysql Instance' component: tools workingDir: ${PROJECTS_ROOT} - commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml' + commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 .mvnw' group: kind: build isDefault: true - - id: build + - id: run exec: label: 'Package the application with yarn' component: tools workingDir: ${PROJECTS_ROOT} - commandLine: 'yarn install' - group: - kind: build - isDefault: true - - id: run-frontend - exec: - label: 'Run Frontend' - component: tools - workingDir: ${PROJECT_SOURCE} - commandLine: 'yarn start' - group: - kind: build - isDefault: true - - id: run-backend - exec: - label: 'Run Backend' - component: tools - workingDir: ${PROJECT_SOURCE} - commandLine: 'chmod 777 .mvnw && ./mvnw' + commandLine: 'yarn start && ./mvnw' group: kind: run isDefault: true From b70ce1099545e448b4d5c1ebb99e7fa064ae40ca Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 18:53:39 +0000 Subject: [PATCH 10/37] devfile.yaml --- devfile.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index 473e1fe5..55b81174 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -54,16 +54,16 @@ commands: exec: label: 'Package the application with yarn and create Mysql Instance' component: tools - workingDir: ${PROJECTS_ROOT} + workingDir: ${PROJECTS_ROOT}/jhipster-online commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 .mvnw' group: kind: build isDefault: true - id: run exec: - label: 'Package the application with yarn' + label: 'Run yarn start && ./mvnw' component: tools - workingDir: ${PROJECTS_ROOT} + workingDir: ${PROJECTS_ROOT}/jhipster-online commandLine: 'yarn start && ./mvnw' group: kind: run From 789d5072d3ca614bcf8b65a133c0dceffe32eec7 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 19:13:18 +0000 Subject: [PATCH 11/37] devfile.yaml --- devfile.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devfile.yaml b/devfile.yaml index 55b81174..f489cd7c 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -55,7 +55,7 @@ commands: label: 'Package the application with yarn and create Mysql Instance' component: tools workingDir: ${PROJECTS_ROOT}/jhipster-online - commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 .mvnw' + commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 ./mvnw' group: kind: build isDefault: true From 81e46cd3385418d2739284fa33addc3d4628e317 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 19:22:38 +0000 Subject: [PATCH 12/37] devfile.yaml --- devfile.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devfile.yaml b/devfile.yaml index f489cd7c..9adb43dd 100644 --- a/devfile.yaml +++ b/devfile.yaml @@ -55,16 +55,16 @@ commands: label: 'Package the application with yarn and create Mysql Instance' component: tools workingDir: ${PROJECTS_ROOT}/jhipster-online - commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 ./mvnw' + commandLine: 'oc apply -f src/main/kubernetes/mysql.yaml && yarn install && chmod 777 ./mvnw && echo "do not kill this task, run ./mvnw in other tasks" && yarn start ' group: kind: build isDefault: true - id: run exec: - label: 'Run yarn start && ./mvnw' + label: 'Run ./mvnw' component: tools workingDir: ${PROJECTS_ROOT}/jhipster-online - commandLine: 'yarn start && ./mvnw' + commandLine: './mvnw' group: kind: run isDefault: true From bafebda3f4f3c7676c214306f1330f569ff4b02e Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Thu, 5 Sep 2024 21:30:24 +0000 Subject: [PATCH 13/37] works with mariadb --- src/main/kubernetes/mysql.yaml | 8 +++-- src/main/resources/config/application-dev.yml | 29 +++++++++++++------ src/main/resources/config/application.yml | 4 ++- .../00000000000000_initial_schema.xml | 15 ++++++---- ...0171116094805_added_entity_JdlMetadata.xml | 13 +++------ .../changelog/20180620133843_gitlab.xml | 11 +++++-- 6 files changed, 50 insertions(+), 30 deletions(-) diff --git a/src/main/kubernetes/mysql.yaml b/src/main/kubernetes/mysql.yaml index 9f61ad9c..57be1946 100644 --- a/src/main/kubernetes/mysql.yaml +++ b/src/main/kubernetes/mysql.yaml @@ -3,9 +3,10 @@ apiVersion: v1 metadata: name: mariadb labels: - app.openshift.io/runtime: mariadb - template: mariadb-ephemeral-template - template.openshift.io/template-instance-owner: 5141732c-e33c-4366-82db-f5775278edc6 + app: mariadb + app.kubernetes.io/instance: mariadb + app.kubernetes.io/name: mariadb + app.kubernetes.io/part-of: mariadb annotations: template.openshift.io/expose-database_name: "{.data['database-name']}" template.openshift.io/expose-password: "{.data['database-password']}" @@ -146,6 +147,7 @@ kind: PersistentVolumeClaim metadata: name: mariadb-data labels: + app: mariadb app.kubernetes.io/instance: mariadb app.kubernetes.io/name: mariadb app.kubernetes.io/part-of: mariadb diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 2357a1ff..55960c5c 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -31,12 +31,12 @@ spring: indent-output: true datasource: type: com.zaxxer.hikari.HikariDataSource - url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true - username: root - password: - # url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline - # username: jhipster - # password: jhipster + #url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true + #username: root + #password: + url: jdbc:mariadb://mariadb.maximilianopizarro5-dev.svc.cluster.local:3306/jhipsteronline + username: jhipster + password: jhipster hikari: poolName: Hikari auto-commit: false @@ -82,17 +82,19 @@ jhipster: max-entries: 100 # Number of objects in each cache entry # CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API cors: - allowed-origins: '*' + allowed-origins: 'http://localhost:8080,https://localhost:8100,http://localhost:9000,https://localhost:9000,http://localhost:9060,https://localhost:9060' + # Enable CORS when running in Dev Spaces + allowed-origin-patterns: 'https://*.apps.sandbox-m2.ll9k.p1.openshiftapps.com' allowed-methods: '*' allowed-headers: '*' - exposed-headers: 'Authorization,Link,X-Total-Count' + exposed-headers: 'Authorization,Link,X-Total-Count,X-${jhipster.clientApp.name}-alert,X-${jhipster.clientApp.name}-error,X-${jhipster.clientApp.name}-params' allow-credentials: true max-age: 1800 security: authentication: jwt: # This token must be encoded using Base64 and be at least 256 bits long (you can type `openssl rand -base64 64` on your command line to generate a 512 bits one) - base64-secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + base64-secret: ZjA0MzBhNGRmZWY4NGJiMTdiMzY2YzFiNzQwOWY4MjZmMzZhM2I5NDYyODgzMGI1MzA0M2JkMDY1NDgzNmViOGVjZDQzYTRjMWY3NmEyOTc1ZDQxOTAwYzAwZDMxNTQ3NmI1ZTMwNDEyYTM5YjU0ZGYyZWNlN2VkODg1ODlmOWE= # Token is valid 24 hours token-validity-in-seconds: 86400 token-validity-in-seconds-for-remember-me: 2592000 @@ -119,6 +121,15 @@ jhipster: # https://www.jhipster.tech/common-application-properties/ # =================================================================== +application: + tmp-folder: /tmp + jhipster-cmd: + cmd: jhipster + timeout: 120 + github: + host: https://github.com + client-id: Ov23liMrrNkpqCrsYH83 + client-secret: df42d268e1a835c5a18b8e48ec2562bcf0d99caf #application: # tmp-folder: /tmp # jhipster-cmd: diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index ecc9de39..b7399c6a 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -80,7 +80,9 @@ spring: jpa: open-in-view: false properties: - # hibernate.jdbc.time_zone: UTC + hibernate.jdbc.time_zone: UTC + hibernate.timezone.default_storage: NORMALIZE + hibernate.type.preferred_instant_jdbc_type: TIMESTAMP hibernate.id.new_generator_mappings: true hibernate.connection.provider_disables_autocommit: true hibernate.cache.use_second_level_cache: true diff --git a/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml b/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml index 94263f0f..697f45ef 100644 --- a/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml +++ b/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml @@ -5,16 +5,21 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> + + - + + + + - + @@ -41,7 +46,7 @@ - + @@ -108,7 +113,7 @@ separator=";" tableName="jhi_user_authority"/> - + @@ -119,7 +124,7 @@ - + diff --git a/src/main/resources/config/liquibase/changelog/20171116094805_added_entity_JdlMetadata.xml b/src/main/resources/config/liquibase/changelog/20171116094805_added_entity_JdlMetadata.xml index 4e0f4608..37bb1ae6 100644 --- a/src/main/resources/config/liquibase/changelog/20171116094805_added_entity_JdlMetadata.xml +++ b/src/main/resources/config/liquibase/changelog/20171116094805_added_entity_JdlMetadata.xml @@ -30,11 +30,11 @@ - + - + @@ -72,7 +72,7 @@ - + diff --git a/src/main/resources/config/liquibase/changelog/20180620133843_gitlab.xml b/src/main/resources/config/liquibase/changelog/20180620133843_gitlab.xml index 856ada9a..41ebf79b 100644 --- a/src/main/resources/config/liquibase/changelog/20180620133843_gitlab.xml +++ b/src/main/resources/config/liquibase/changelog/20180620133843_gitlab.xml @@ -46,17 +46,22 @@ constraintName="FKrwcmar7keuxrohh69romyiown" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="jhi_user"/> + + + + + + From c29e01c524726e6368e6f597cbb04437cfde85f4 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 14:48:36 +0000 Subject: [PATCH 14/37] application-dev --- src/main/resources/config/application-dev.yml | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 55960c5c..541b26e8 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -31,12 +31,12 @@ spring: indent-output: true datasource: type: com.zaxxer.hikari.HikariDataSource - #url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true - #username: root - #password: - url: jdbc:mariadb://mariadb.maximilianopizarro5-dev.svc.cluster.local:3306/jhipsteronline - username: jhipster - password: jhipster + url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true + username: root + password: + #url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline + #username: jhipster + #password: jhipster hikari: poolName: Hikari auto-commit: false @@ -121,15 +121,6 @@ jhipster: # https://www.jhipster.tech/common-application-properties/ # =================================================================== -application: - tmp-folder: /tmp - jhipster-cmd: - cmd: jhipster - timeout: 120 - github: - host: https://github.com - client-id: Ov23liMrrNkpqCrsYH83 - client-secret: df42d268e1a835c5a18b8e48ec2562bcf0d99caf #application: # tmp-folder: /tmp # jhipster-cmd: From 69113e4a8e4859a1795dcec731800623fd4fea3d Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 17:20:03 +0000 Subject: [PATCH 15/37] application-dev.yaml --- src/main/resources/config/application-dev.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 541b26e8..037bb353 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -31,12 +31,12 @@ spring: indent-output: true datasource: type: com.zaxxer.hikari.HikariDataSource - url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true - username: root - password: - #url: jdbc:mariadb://mariadb..svc.cluster.local:3306/jhipsteronline - #username: jhipster - #password: jhipster + #url: jdbc:mysql://localhost:3306/jhipster-online?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true + #username: root + #password: + url: jdbc:mariadb://mariadb.maximilianopizarro5-dev.svc.cluster.local:3306/jhipsteronline + username: jhipster + password: jhipster hikari: poolName: Hikari auto-commit: false From bc6abfc9a62d4dd8a76c668027d108a6839008f8 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 18:45:55 +0000 Subject: [PATCH 16/37] Tekton Pipeline --- README.md | 7 + src/main/kubernetes/tkn-pipeline-run.yaml | 32 +++ src/main/kubernetes/tkn-pipeline.yaml | 236 ++++++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 src/main/kubernetes/tkn-pipeline-run.yaml create mode 100644 src/main/kubernetes/tkn-pipeline.yaml diff --git a/README.md b/README.md index 7b15e502..55905f1c 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,13 @@ yarn install && yarn start ./mvnw -Pdev ``` +### Tekton Pipeline + +``` +oc apply -f src/main/kubernetes/tkn-pipeline.yaml +oc apply -f src/main/kubernetes/tkn-pipeline-run.yaml +``` + ## Deployment to Google App Engine (GAE) Flexible Environment - The project can be deployed to [GAE flexible environment](https://cloud.google.com/appengine/docs/flexible/) by simply [creating a tagged release](https://github.com/jhipster/jhipster-online/releases). diff --git a/src/main/kubernetes/tkn-pipeline-run.yaml b/src/main/kubernetes/tkn-pipeline-run.yaml new file mode 100644 index 00000000..007a3dd6 --- /dev/null +++ b/src/main/kubernetes/tkn-pipeline-run.yaml @@ -0,0 +1,32 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: jhipster-devspace + labels: + tekton.dev/pipeline: jhipster-devspace +spec: + params: + - name: IMAGE_NAME + value: 'image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster' + - name: PATH_CONTEXT + value: / + - name: MAVEN_IMAGE + value: 'registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5' + - name: APP_JAR_VERSION + value: appdemo-0.0.1-SNAPSHOT.jar + - name: APP_NAME + value: jhipster + - name: GIT_REPO + value: 'https://github.com/maximilianoPizarro/app-demo-jhipster-react' + - name: GIT_BRANCH + value: main + pipelineRef: + name: jhipster-devspace + taskRunTemplate: + serviceAccountName: pipeline + timeouts: + pipeline: 1h0m0s + workspaces: + - name: workspace + persistentVolumeClaim: + claimName: workspace diff --git a/src/main/kubernetes/tkn-pipeline.yaml b/src/main/kubernetes/tkn-pipeline.yaml new file mode 100644 index 00000000..324e7c81 --- /dev/null +++ b/src/main/kubernetes/tkn-pipeline.yaml @@ -0,0 +1,236 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: workspace + labels: + app.kubernetes.io/instance: delivery + app.kubernetes.io/name: delivery + app.kubernetes.io/part-of: delivery +spec: + accessModes: + - ReadWriteOnce + volumeMode: Filesystem + resources: + requests: + storage: 2Gi +--- +apiVersion: tekton.dev/v1 +kind: Task +metadata: + name: npm +spec: + description: >- + This task can be used to run npm goals on a project. + + This task can be used to run npm goals on a project where package.json is + present and has some pre-defined npm scripts. + params: + - default: . + description: The path where package.json of the project is defined. + name: PATH_CONTEXT + type: string + - default: + - version + description: The npm goals you want to run. + name: ARGS + type: array + - default: 'docker.io/library/node:18.18.2-alpine' + description: The node image you want to use. + name: IMAGE + type: string + steps: + - args: + - $(params.ARGS) + command: + - npm + computeResources: {} + env: + - name: CI + value: 'true' + image: $(params.IMAGE) + name: npm-run + workingDir: $(workspaces.source.path)/$(params.PATH_CONTEXT) + workspaces: + - name: source +--- +apiVersion: tekton.dev/v1 +kind: Pipeline +metadata: + name: jhipster-devspace +spec: + params: + - default: >- + image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster + name: IMAGE_NAME + type: string + - default: / + name: PATH_CONTEXT + type: string + - default: >- + registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5 + name: MAVEN_IMAGE + type: string + - default: appdemo-0.0.1-SNAPSHOT.jar + name: APP_JAR_VERSION + type: string + - default: jhipster + name: APP_NAME + type: string + - default: 'https://github.com/maximilianoPizarro/app-demo-jhipster-react' + name: GIT_REPO + type: string + - default: main + name: GIT_BRANCH + type: string + tasks: + - name: maven + params: + - name: MAVEN_IMAGE + value: >- + registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5 + - name: GOALS + value: + - clean + - verify + - '-Pprod' + - >- + -Dmaven.repo.local=$(workspaces.source.path)/$(params.PATH_CONTEXT)/.m2 + - '-Dmaven.test.skip=true' + - name: MAVEN_MIRROR_URL + value: '' + - name: SERVER_USER + value: '' + - name: SERVER_PASSWORD + value: '' + - name: PROXY_USER + value: '' + - name: PROXY_PASSWORD + value: '' + - name: PROXY_PORT + value: '' + - name: PROXY_HOST + value: '' + - name: PROXY_NON_PROXY_HOSTS + value: '' + - name: PROXY_PROTOCOL + value: http + - name: CONTEXT_DIR + value: $(params.PATH_CONTEXT) + runAfter: + - npm + taskRef: + kind: ClusterTask + name: maven + workspaces: + - name: source + workspace: workspace + - name: maven-settings + workspace: workspace + - name: git-clone + params: + - name: url + value: $(params.GIT_REPO) + - name: revision + value: $(params.GIT_BRANCH) + - name: refspec + value: '' + - name: submodules + value: 'true' + - name: depth + value: '1' + - name: sslVerify + value: 'true' + - name: crtFileName + value: ca-bundle.crt + - name: subdirectory + value: '' + - name: sparseCheckoutDirectories + value: '' + - name: deleteExisting + value: 'true' + - name: httpProxy + value: '' + - name: httpsProxy + value: '' + - name: noProxy + value: '' + - name: verbose + value: 'true' + - name: gitInitImage + value: >- + registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:c4b2183f7c7997bd401d86b33eefb637b3ef2fa90618e875106292cd69a15c14 + - name: userHome + value: /home/git + taskRef: + kind: ClusterTask + name: git-clone + workspaces: + - name: output + workspace: workspace + - name: npm + params: + - name: PATH_CONTEXT + value: $(params.PATH_CONTEXT) + - name: ARGS + value: + - install + - name: IMAGE + value: 'docker.io/library/node:18.18.2-alpine' + runAfter: + - oc-apply-manifest + taskRef: + kind: Task + name: npm + workspaces: + - name: source + workspace: workspace + - name: s2i-binary-build + params: + - name: SCRIPT + value: >- + oc start-build jhipster-devspace + --from-file=$(workspaces.manifest-dir.path)/$(params.PATH_CONTEXT)/target/$(params.APP_JAR_VERSION) + - name: VERSION + value: latest + runAfter: + - maven + taskRef: + kind: ClusterTask + name: openshift-client + workspaces: + - name: manifest-dir + workspace: workspace + - name: deploy + params: + - name: SCRIPT + value: oc rollout status deploy/$(params.APP_NAME) + - name: VERSION + value: latest + runAfter: + - s2i-binary-build + taskRef: + kind: ClusterTask + name: openshift-client + workspaces: + - name: manifest-dir + workspace: workspace + - name: oc-apply-manifest + params: + - name: SCRIPT + value: >- + oc apply -f + https://raw.githubusercontent.com/maximilianoPizarro/jhipster-devspace/master/template.yaml + - name: VERSION + value: latest + runAfter: + - git-clone + taskRef: + kind: ClusterTask + name: openshift-client + workspaces: + - name: manifest-dir + workspace: workspace + workspaces: + - name: workspace + optional: false + finally: [] From 8f4cb13a7ca5c70b4d9ae78447da57cde2e60e39 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 18:58:14 +0000 Subject: [PATCH 17/37] README --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 55905f1c..016963d1 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,19 @@ oc apply -f src/main/kubernetes/tkn-pipeline.yaml oc apply -f src/main/kubernetes/tkn-pipeline-run.yaml ``` +Example + +``` +tkn pipeline start jhipster-devspace \ + --param IMAGE_NAME='image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster'\ + --param PATH_CONTEXT=/app \ + --param APP_JAR_VERSION=delivery-0.0.1-SNAPSHOT.jar \ + --param APP_NAME=jhipster \ + --param GIT_REPO=https://github.com/maximilianoPizarro/jhipster-devspace \ + --param GIT_BRANCH=master \ + --workspace name=workspace,claimName=workspace +``` + ## Deployment to Google App Engine (GAE) Flexible Environment - The project can be deployed to [GAE flexible environment](https://cloud.google.com/appengine/docs/flexible/) by simply [creating a tagged release](https://github.com/jhipster/jhipster-online/releases). From 8e78436f68ddca3da558eccc4e34bb1f359b4e65 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 19:43:24 +0000 Subject: [PATCH 18/37] tkn pipeline start --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 016963d1..cce25e52 100644 --- a/README.md +++ b/README.md @@ -228,13 +228,15 @@ Example ``` tkn pipeline start jhipster-devspace \ - --param IMAGE_NAME='image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster'\ - --param PATH_CONTEXT=/app \ - --param APP_JAR_VERSION=delivery-0.0.1-SNAPSHOT.jar \ - --param APP_NAME=jhipster \ - --param GIT_REPO=https://github.com/maximilianoPizarro/jhipster-devspace \ - --param GIT_BRANCH=master \ - --workspace name=workspace,claimName=workspace + -w name=workspace,claimName=workspace \ + -p PATH_CONTEXT=/app \ + -p IMAGE_NAME=image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster \ + -p APP_JAR_VERSION=delivery-0.0.1-SNAPSHOT.jar \ + -p APP_NAME=jhipster \ + -p GIT_REPO=https://github.com/maximilianoPizarro/jhipster-devspace \ + -p GIT_BRANCH=master \ + -p MAVEN_IMAGE=registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5 \ + --showlog ``` ## Deployment to Google App Engine (GAE) Flexible Environment From bc6a0d963e6b9e22e9f002b110399a345fdafbff Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Fri, 6 Sep 2024 19:55:42 +0000 Subject: [PATCH 19/37] readme tekton pipeline --- README.md | 7 +++- .../kubernetes/tkn-pipeline-run-jhipster.yaml | 32 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/main/kubernetes/tkn-pipeline-run-jhipster.yaml diff --git a/README.md b/README.md index cce25e52..d28cb73b 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,12 @@ yarn install && yarn start ``` oc apply -f src/main/kubernetes/tkn-pipeline.yaml -oc apply -f src/main/kubernetes/tkn-pipeline-run.yaml +``` + +Example + +``` +oc apply -f src/main/kubernetes/tkn-pipeline-run-jhipster.yaml ``` Example diff --git a/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml b/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml new file mode 100644 index 00000000..66c3e968 --- /dev/null +++ b/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml @@ -0,0 +1,32 @@ +apiVersion: tekton.dev/v1 +kind: PipelineRun +metadata: + name: jhipster-devspace + labels: + tekton.dev/pipeline: jhipster-devspace +spec: + params: + - name: IMAGE_NAME + value: 'image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster' + - name: PATH_CONTEXT + value: /app + - name: MAVEN_IMAGE + value: 'registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5' + - name: APP_JAR_VERSION + value: delivery-0.0.1-SNAPSHOT.jar + - name: APP_NAME + value: jhipster + - name: GIT_REPO + value: 'https://github.com/maximilianoPizarro/jhipster-devspace' + - name: GIT_BRANCH + value: master + pipelineRef: + name: jhipster-devspace + taskRunTemplate: + serviceAccountName: pipeline + timeouts: + pipeline: 1h0m0s + workspaces: + - name: workspace + persistentVolumeClaim: + claimName: workspace From 5e34ca9c68296fce9596125e74df1289204fa685 Mon Sep 17 00:00:00 2001 From: Maximiliano Pizarro Date: Mon, 9 Sep 2024 18:18:04 +0000 Subject: [PATCH 20/37] create with openshift --- .../online/service/GeneratorService.java | 27 ++ .../kubernetes/tkn-pipeline-run-jhipster.yaml | 32 --- src/main/kubernetes/tkn-pipeline-run.yaml | 32 --- src/main/kubernetes/tkn-pipeline.yaml | 236 ------------------ src/main/resources/config/application-dev.yml | 5 + src/main/webapp/app/home/home.component.html | 8 + src/main/webapp/app/home/home.module.ts | 2 + src/main/webapp/app/home/home.route.ts | 2 + .../openshift-generator.component.html | 43 ++++ .../openshift-generator.component.ts | 64 +++++ .../openshift-generator.route.ts | 31 +++ .../webapp/content/images/openshift-logo.svg | 51 ++++ 12 files changed, 233 insertions(+), 300 deletions(-) delete mode 100644 src/main/kubernetes/tkn-pipeline-run-jhipster.yaml delete mode 100644 src/main/kubernetes/tkn-pipeline-run.yaml delete mode 100644 src/main/kubernetes/tkn-pipeline.yaml create mode 100644 src/main/webapp/app/home/openshift-generator/openshift-generator.component.html create mode 100644 src/main/webapp/app/home/openshift-generator/openshift-generator.component.ts create mode 100644 src/main/webapp/app/home/openshift-generator/openshift-generator.route.ts create mode 100644 src/main/webapp/content/images/openshift-logo.svg diff --git a/src/main/java/io/github/jhipster/online/service/GeneratorService.java b/src/main/java/io/github/jhipster/online/service/GeneratorService.java index 60398276..7b4232d4 100644 --- a/src/main/java/io/github/jhipster/online/service/GeneratorService.java +++ b/src/main/java/io/github/jhipster/online/service/GeneratorService.java @@ -26,12 +26,15 @@ import java.io.IOException; import java.io.PrintWriter; import java.net.URISyntaxException; +import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.eclipse.jgit.api.errors.GitAPIException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.util.StopWatch; import org.zeroturnaround.zip.ZipUtil; @@ -57,6 +60,12 @@ public class GeneratorService { private final LogsService logsService; + @Value("${openshift.devspace.url-devfile}") + private String devSpaces; + + @Value("${openshift.tekton.url-pipeline}") + private String pipelineJhipster; + public GeneratorService( ApplicationProperties applicationProperties, GitService gitService, @@ -102,6 +111,10 @@ private File generateApplication(String applicationId, String applicationConfigu FileUtils.forceMkdir(workingDir); this.generateYoRc(applicationId, workingDir, applicationConfiguration); log.info(".yo-rc.json created"); + this.generateDevSpaces(applicationId, workingDir); + log.info("devfile.yaml created"); + this.generateTektonPipeline(applicationId, workingDir); + log.info("pipeline.yaml created"); this.jHipsterService.generateApplication(applicationId, workingDir); log.info("Application generated"); return workingDir; @@ -115,6 +128,20 @@ private void generateYoRc(String applicationId, File workingDir, String applicat writer.close(); } + private void generateDevSpaces(String applicationId, File workingDir) throws IOException { + this.logsService.addLog(applicationId, "Creating `devfile.yaml` file"); + PrintWriter writer = new PrintWriter(workingDir + "/devfile.yaml", StandardCharsets.UTF_8); + writer.print(IOUtils.toString(new URL(devSpaces).openStream(), StandardCharsets.UTF_8)); + writer.close(); + } + + private void generateTektonPipeline(String applicationId, File workingDir) throws IOException { + this.logsService.addLog(applicationId, "Creating `pipeline.yaml` file"); + PrintWriter writer = new PrintWriter(workingDir + "/pipeline.yaml", StandardCharsets.UTF_8); + writer.print(IOUtils.toString(new URL(pipelineJhipster).openStream(), StandardCharsets.UTF_8)); + writer.close(); + } + private void zipResult(File workingDir) { ZipUtil.pack(workingDir, new File(workingDir + ".zip")); } diff --git a/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml b/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml deleted file mode 100644 index 66c3e968..00000000 --- a/src/main/kubernetes/tkn-pipeline-run-jhipster.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: tekton.dev/v1 -kind: PipelineRun -metadata: - name: jhipster-devspace - labels: - tekton.dev/pipeline: jhipster-devspace -spec: - params: - - name: IMAGE_NAME - value: 'image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster' - - name: PATH_CONTEXT - value: /app - - name: MAVEN_IMAGE - value: 'registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5' - - name: APP_JAR_VERSION - value: delivery-0.0.1-SNAPSHOT.jar - - name: APP_NAME - value: jhipster - - name: GIT_REPO - value: 'https://github.com/maximilianoPizarro/jhipster-devspace' - - name: GIT_BRANCH - value: master - pipelineRef: - name: jhipster-devspace - taskRunTemplate: - serviceAccountName: pipeline - timeouts: - pipeline: 1h0m0s - workspaces: - - name: workspace - persistentVolumeClaim: - claimName: workspace diff --git a/src/main/kubernetes/tkn-pipeline-run.yaml b/src/main/kubernetes/tkn-pipeline-run.yaml deleted file mode 100644 index 007a3dd6..00000000 --- a/src/main/kubernetes/tkn-pipeline-run.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: tekton.dev/v1 -kind: PipelineRun -metadata: - name: jhipster-devspace - labels: - tekton.dev/pipeline: jhipster-devspace -spec: - params: - - name: IMAGE_NAME - value: 'image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster' - - name: PATH_CONTEXT - value: / - - name: MAVEN_IMAGE - value: 'registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5' - - name: APP_JAR_VERSION - value: appdemo-0.0.1-SNAPSHOT.jar - - name: APP_NAME - value: jhipster - - name: GIT_REPO - value: 'https://github.com/maximilianoPizarro/app-demo-jhipster-react' - - name: GIT_BRANCH - value: main - pipelineRef: - name: jhipster-devspace - taskRunTemplate: - serviceAccountName: pipeline - timeouts: - pipeline: 1h0m0s - workspaces: - - name: workspace - persistentVolumeClaim: - claimName: workspace diff --git a/src/main/kubernetes/tkn-pipeline.yaml b/src/main/kubernetes/tkn-pipeline.yaml deleted file mode 100644 index 324e7c81..00000000 --- a/src/main/kubernetes/tkn-pipeline.yaml +++ /dev/null @@ -1,236 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: workspace - labels: - app.kubernetes.io/instance: delivery - app.kubernetes.io/name: delivery - app.kubernetes.io/part-of: delivery -spec: - accessModes: - - ReadWriteOnce - volumeMode: Filesystem - resources: - requests: - storage: 2Gi ---- -apiVersion: tekton.dev/v1 -kind: Task -metadata: - name: npm -spec: - description: >- - This task can be used to run npm goals on a project. - - This task can be used to run npm goals on a project where package.json is - present and has some pre-defined npm scripts. - params: - - default: . - description: The path where package.json of the project is defined. - name: PATH_CONTEXT - type: string - - default: - - version - description: The npm goals you want to run. - name: ARGS - type: array - - default: 'docker.io/library/node:18.18.2-alpine' - description: The node image you want to use. - name: IMAGE - type: string - steps: - - args: - - $(params.ARGS) - command: - - npm - computeResources: {} - env: - - name: CI - value: 'true' - image: $(params.IMAGE) - name: npm-run - workingDir: $(workspaces.source.path)/$(params.PATH_CONTEXT) - workspaces: - - name: source ---- -apiVersion: tekton.dev/v1 -kind: Pipeline -metadata: - name: jhipster-devspace -spec: - params: - - default: >- - image-registry.openshift-image-registry.svc:5000/maximilianopizarro5-dev/jhipster - name: IMAGE_NAME - type: string - - default: / - name: PATH_CONTEXT - type: string - - default: >- - registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5 - name: MAVEN_IMAGE - type: string - - default: appdemo-0.0.1-SNAPSHOT.jar - name: APP_JAR_VERSION - type: string - - default: jhipster - name: APP_NAME - type: string - - default: 'https://github.com/maximilianoPizarro/app-demo-jhipster-react' - name: GIT_REPO - type: string - - default: main - name: GIT_BRANCH - type: string - tasks: - - name: maven - params: - - name: MAVEN_IMAGE - value: >- - registry.redhat.io/ubi8/openjdk-17@sha256:af305e087061cbaa4107ce0b304a1ef987f6b54bae3f75bfd529cfd084cba9b5 - - name: GOALS - value: - - clean - - verify - - '-Pprod' - - >- - -Dmaven.repo.local=$(workspaces.source.path)/$(params.PATH_CONTEXT)/.m2 - - '-Dmaven.test.skip=true' - - name: MAVEN_MIRROR_URL - value: '' - - name: SERVER_USER - value: '' - - name: SERVER_PASSWORD - value: '' - - name: PROXY_USER - value: '' - - name: PROXY_PASSWORD - value: '' - - name: PROXY_PORT - value: '' - - name: PROXY_HOST - value: '' - - name: PROXY_NON_PROXY_HOSTS - value: '' - - name: PROXY_PROTOCOL - value: http - - name: CONTEXT_DIR - value: $(params.PATH_CONTEXT) - runAfter: - - npm - taskRef: - kind: ClusterTask - name: maven - workspaces: - - name: source - workspace: workspace - - name: maven-settings - workspace: workspace - - name: git-clone - params: - - name: url - value: $(params.GIT_REPO) - - name: revision - value: $(params.GIT_BRANCH) - - name: refspec - value: '' - - name: submodules - value: 'true' - - name: depth - value: '1' - - name: sslVerify - value: 'true' - - name: crtFileName - value: ca-bundle.crt - - name: subdirectory - value: '' - - name: sparseCheckoutDirectories - value: '' - - name: deleteExisting - value: 'true' - - name: httpProxy - value: '' - - name: httpsProxy - value: '' - - name: noProxy - value: '' - - name: verbose - value: 'true' - - name: gitInitImage - value: >- - registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:c4b2183f7c7997bd401d86b33eefb637b3ef2fa90618e875106292cd69a15c14 - - name: userHome - value: /home/git - taskRef: - kind: ClusterTask - name: git-clone - workspaces: - - name: output - workspace: workspace - - name: npm - params: - - name: PATH_CONTEXT - value: $(params.PATH_CONTEXT) - - name: ARGS - value: - - install - - name: IMAGE - value: 'docker.io/library/node:18.18.2-alpine' - runAfter: - - oc-apply-manifest - taskRef: - kind: Task - name: npm - workspaces: - - name: source - workspace: workspace - - name: s2i-binary-build - params: - - name: SCRIPT - value: >- - oc start-build jhipster-devspace - --from-file=$(workspaces.manifest-dir.path)/$(params.PATH_CONTEXT)/target/$(params.APP_JAR_VERSION) - - name: VERSION - value: latest - runAfter: - - maven - taskRef: - kind: ClusterTask - name: openshift-client - workspaces: - - name: manifest-dir - workspace: workspace - - name: deploy - params: - - name: SCRIPT - value: oc rollout status deploy/$(params.APP_NAME) - - name: VERSION - value: latest - runAfter: - - s2i-binary-build - taskRef: - kind: ClusterTask - name: openshift-client - workspaces: - - name: manifest-dir - workspace: workspace - - name: oc-apply-manifest - params: - - name: SCRIPT - value: >- - oc apply -f - https://raw.githubusercontent.com/maximilianoPizarro/jhipster-devspace/master/template.yaml - - name: VERSION - value: latest - runAfter: - - git-clone - taskRef: - kind: ClusterTask - name: openshift-client - workspaces: - - name: manifest-dir - workspace: workspace - workspaces: - - name: workspace - optional: false - finally: [] diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml index 037bb353..b69761f7 100644 --- a/src/main/resources/config/application-dev.yml +++ b/src/main/resources/config/application-dev.yml @@ -112,6 +112,11 @@ jhipster: audit-events: retention-period: 30 # Number of days before audit events are deleted. +openshift: + devspace: + url-devfile: https://raw.githubusercontent.com/maximilianoPizarro/jhipster-devspace/master/jhipster-devspaces.yaml + tekton: + url-pipeline: https://raw.githubusercontent.com/maximilianoPizarro/jhipster-devspace/master/jhipster-pipeline.yaml # =================================================================== # Application specific properties # Add your own application properties here, see the ApplicationProperties class diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index d098c058..70dbaf49 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -51,6 +51,14 @@ Create Azure Application +