Add configuration of ci/cd process

Change-Id: I540b00dd35915665d355ee4348323f2a6e17c352
This commit is contained in:
jmarchel 2024-02-27 10:28:50 +01:00 committed by Jan Marchel
parent 40ce0e367c
commit 9e3f726444
13 changed files with 56 additions and 147 deletions

View File

@ -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/

View File

@ -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"

View File

@ -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

View File

@ -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 }}

View File

@ -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

View File

@ -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/

View File

@ -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"]

View File

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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() {
}
}

View File

@ -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