From 9e3f726444389954af3a29bb9400fe774b2c2d3a Mon Sep 17 00:00:00 2001 From: jmarchel Date: Tue, 27 Feb 2024 10:28:50 +0100 Subject: [PATCH] Add configuration of ci/cd process Change-Id: I540b00dd35915665d355ee4348323f2a6e17c352 --- Dockerfile | 3 +- charts/nebulous-gui-controller/Chart.yaml | 5 +++ .../templates/add-user-to-csm.yaml | 25 +++++++++++ .../templates/deployment.yaml | 14 +++---- charts/nebulous-gui-controller/values.yaml | 16 ++++++- java-spring-boot-demo/.gitignore | 33 --------------- java-spring-boot-demo/Dockerfile | 15 ------- java-spring-boot-demo/pom.xml | 42 ------------------- .../com/example/demo/DemoApplication.java | 13 ------ .../java/com/example/demo/DemoController.java | 14 ------- .../src/main/resources/application.properties | 0 .../example/demo/DemoApplicationTests.java | 13 ------ zuul.d/jobs.yaml | 10 ++--- 13 files changed, 56 insertions(+), 147 deletions(-) create mode 100644 charts/nebulous-gui-controller/templates/add-user-to-csm.yaml delete mode 100644 java-spring-boot-demo/.gitignore delete mode 100644 java-spring-boot-demo/Dockerfile delete mode 100644 java-spring-boot-demo/pom.xml delete mode 100644 java-spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java delete mode 100644 java-spring-boot-demo/src/main/java/com/example/demo/DemoController.java delete mode 100644 java-spring-boot-demo/src/main/resources/application.properties delete mode 100644 java-spring-boot-demo/src/test/java/com/example/demo/DemoApplicationTests.java diff --git a/Dockerfile b/Dockerfile index 6eea4e9..c37f9df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,8 @@ USER node COPY --chown=node package*.json /srv/www/apostrophe/ ENV NODE_ENV=production -RUN npm ci + +RUN npm install COPY --chown=node . /srv/www/apostrophe/ diff --git a/charts/nebulous-gui-controller/Chart.yaml b/charts/nebulous-gui-controller/Chart.yaml index 5510512..f834f0b 100644 --- a/charts/nebulous-gui-controller/Chart.yaml +++ b/charts/nebulous-gui-controller/Chart.yaml @@ -22,3 +22,8 @@ version: 0.1.0 # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. appVersion: "latest" + +dependencies: + - name: mongodb + version: 14.12.1 + repository: "https://charts.bitnami.com/bitnami" diff --git a/charts/nebulous-gui-controller/templates/add-user-to-csm.yaml b/charts/nebulous-gui-controller/templates/add-user-to-csm.yaml new file mode 100644 index 0000000..7cb7279 --- /dev/null +++ b/charts/nebulous-gui-controller/templates/add-user-to-csm.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: add-admin-user + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-weight": "5" + "helm.sh/hook-delete-policy": hook-succeeded + labels: + app: + {{- include "nebulous-gui-controller.labels" . | nindent 4 }} +spec: + template: + spec: + initContainers: + - name: wait-for-mongodb + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + command: ['sh', '-c', 'until nc -z nebulous-gui-controller-mongodb 27017; do echo waiting for mongodb; sleep 2; done;'] + containers: + - name: add-admin-user + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + command: ["node"] + args: ["app.js", "@apostrophecms/user:add", "{{ .Values.apostropheCMS.user.name }}", "{{ .Values.apostropheCMS.user.password }}"] + restartPolicy: Never + backoffLimit: 4 diff --git a/charts/nebulous-gui-controller/templates/deployment.yaml b/charts/nebulous-gui-controller/templates/deployment.yaml index 01cd76f..d9f76eb 100644 --- a/charts/nebulous-gui-controller/templates/deployment.yaml +++ b/charts/nebulous-gui-controller/templates/deployment.yaml @@ -27,6 +27,10 @@ spec: serviceAccountName: {{ include "nebulous-gui-controller.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} + initContainers: + - name: wait-for-mongodb + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + command: ['sh', '-c', 'until nc -z nebulous-gui-controller-mongodb 27017; do echo waiting for mongodb; sleep 2; done;'] containers: - name: {{ .Chart.Name }} securityContext: @@ -35,16 +39,8 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: 8080 + containerPort: 3000 protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} diff --git a/charts/nebulous-gui-controller/values.yaml b/charts/nebulous-gui-controller/values.yaml index b544fe7..15b20d4 100644 --- a/charts/nebulous-gui-controller/values.yaml +++ b/charts/nebulous-gui-controller/values.yaml @@ -5,7 +5,7 @@ replicaCount: 1 image: - repository: "quay.io/nebulous/gui-controller-java-spring-boot-demo" + repository: "quay.io/nebulous/gui-controller" pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" @@ -38,7 +38,7 @@ securityContext: {} service: type: ClusterIP - port: 80 + port: 3000 ingress: enabled: false @@ -80,3 +80,15 @@ nodeSelector: {} tolerations: [] affinity: {} + +mongodb: + auth: + rootPassword: "nebulous-gui" + username: "admin" + password: "nebulous-gui" + database: "gui-controller" + +apostropheCMS: + user: + name: admin + password: admin diff --git a/java-spring-boot-demo/.gitignore b/java-spring-boot-demo/.gitignore deleted file mode 100644 index 549e00a..0000000 --- a/java-spring-boot-demo/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/java-spring-boot-demo/Dockerfile b/java-spring-boot-demo/Dockerfile deleted file mode 100644 index 427e30e..0000000 --- a/java-spring-boot-demo/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -# -# Build stage -# -FROM docker.io/library/maven:3.9.2-eclipse-temurin-17 AS build -COPY src /home/app/src -COPY pom.xml /home/app -RUN mvn -f /home/app/pom.xml clean package - -# -# Package stage -# -FROM docker.io/library/eclipse-temurin:17-jre -COPY --from=build /home/app/target/demo-0.0.1-SNAPSHOT.jar /usr/local/lib/demo.jar -EXPOSE 8080 -ENTRYPOINT ["java","-jar","/usr/local/lib/demo.jar"] diff --git a/java-spring-boot-demo/pom.xml b/java-spring-boot-demo/pom.xml deleted file mode 100644 index 76e0f0e..0000000 --- a/java-spring-boot-demo/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.1.0 - - - com.example - demo - 0.0.1-SNAPSHOT - demo - Demo project for Spring Boot - - 17 - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - diff --git a/java-spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java b/java-spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java deleted file mode 100644 index 094d95b..0000000 --- a/java-spring-boot-demo/src/main/java/com/example/demo/DemoApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/java-spring-boot-demo/src/main/java/com/example/demo/DemoController.java b/java-spring-boot-demo/src/main/java/com/example/demo/DemoController.java deleted file mode 100644 index 61a5075..0000000 --- a/java-spring-boot-demo/src/main/java/com/example/demo/DemoController.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.demo; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class DemoController { - - @RequestMapping("/") - public Object root() { - return null; - } - -} diff --git a/java-spring-boot-demo/src/main/resources/application.properties b/java-spring-boot-demo/src/main/resources/application.properties deleted file mode 100644 index e69de29..0000000 diff --git a/java-spring-boot-demo/src/test/java/com/example/demo/DemoApplicationTests.java b/java-spring-boot-demo/src/test/java/com/example/demo/DemoApplicationTests.java deleted file mode 100644 index eaa9969..0000000 --- a/java-spring-boot-demo/src/test/java/com/example/demo/DemoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 15f15a6..27a37ca 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -8,15 +8,15 @@ - nebulous-gui-controller-container-images description: Build the container images. files: &image_files - - ^java-spring-boot-demo/ + - ^/ vars: &image_vars promote_container_image_job: nebulous-gui-controller-upload-container-images container_images: - - context: java-spring-boot-demo + - context: . registry: quay.io - repository: quay.io/nebulous/gui-controller-java-spring-boot-demo + repository: quay.io/nebulous/gui-controller namespace: nebulous - repo_shortname: gui-controller-java-spring-boot-demo + repo_shortname: gui-controller repo_description: "" - job: @@ -44,7 +44,7 @@ description: Run Hadolint on Dockerfile(s). vars: dockerfiles: - - java-spring-boot-demo/Dockerfile + - Dockerfile - job: name: nebulous-gui-controller-helm-lint