3cd34056 by Adam Heath

Moqui+postgresql+elasticsearch.

1 parent 7666e6b3
...@@ -5,7 +5,7 @@ FROM ${RUNTIME_IMAGE} AS moqui-base ...@@ -5,7 +5,7 @@ FROM ${RUNTIME_IMAGE} AS moqui-base
5 5
6 RUN true \ 6 RUN true \
7 && apt-get update \ 7 && apt-get update \
8 && apt-get install unzip less \ 8 && apt-get install -y unzip less \
9 && apt-get clean && rm -rf /var/lib/apt/lists/* \ 9 && apt-get clean && rm -rf /var/lib/apt/lists/* \
10 && groupadd -g 1000 moqui \ 10 && groupadd -g 1000 moqui \
11 && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \ 11 && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \
...@@ -13,6 +13,14 @@ RUN true \ ...@@ -13,6 +13,14 @@ RUN true \
13 && chown moqui:moqui /opt/moqui \ 13 && chown moqui:moqui /opt/moqui \
14 && true 14 && true
15 15
16 FROM moqui-base AS moqui-jdbc-drivers
17
18 RUN true \
19 && apt-get update \
20 && apt-get install -y libpostgresql-jdbc-java \
21 && apt-get clean && rm -rf /var/lib/apt/lists/* \
22 && true
23
16 # build runs as root; attempting to chown all the copied-in files runs 24 # build runs as root; attempting to chown all the copied-in files runs
17 # *very* slow 25 # *very* slow
18 FROM moqui-base AS moqui-build 26 FROM moqui-base AS moqui-build
...@@ -29,7 +37,7 @@ WORKDIR /opt/moqui ...@@ -29,7 +37,7 @@ WORKDIR /opt/moqui
29 USER moqui 37 USER moqui
30 RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"] 38 RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"]
31 39
32 FROM moqui-base AS moqui-run 40 FROM moqui-base AS moqui-app
33 MAINTAINER Moqui Framework <moqui@googlegroups.com> 41 MAINTAINER Moqui Framework <moqui@googlegroups.com>
34 42
35 USER moqui 43 USER moqui
...@@ -39,7 +47,7 @@ COPY --from=moqui-build /opt/moqui/ /opt/moqui/ ...@@ -39,7 +47,7 @@ COPY --from=moqui-build /opt/moqui/ /opt/moqui/
39 RUN ["ls", "-l", "/opt/moqui/"] 47 RUN ["ls", "-l", "/opt/moqui/"]
40 48
41 # create user for search and chown corresponding files 49 # create user for search and chown corresponding files
42 ARG search_name=opensearch 50 #ARG search_name=opensearch
43 51
44 # This is a fix for previous installs, not needed for new setups. 52 # This is a fix for previous installs, not needed for new setups.
45 # upgrade fix #RUN if [ -d runtime/opensearch/bin ]; then echo "Installing OpenSearch User"; \ 53 # upgrade fix #RUN if [ -d runtime/opensearch/bin ]; then echo "Installing OpenSearch User"; \
...@@ -59,8 +67,8 @@ ARG search_name=opensearch ...@@ -59,8 +67,8 @@ ARG search_name=opensearch
59 RUN ["mkdir", "-p", "/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"] 67 RUN ["mkdir", "-p", "/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
60 VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"] 68 VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
61 # exposed as volumes to persist data outside the container, recommended 69 # exposed as volumes to persist data outside the container, recommended
62 RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"] 70 RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
63 VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"] 71 VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
64 72
65 # Main Servlet Container Port 73 # Main Servlet Container Port
66 EXPOSE 8080 74 EXPOSE 8080
......
1 #!/bin/bash
2
3 TAG=test-latest
4 APP=moqui-app
5 PUSH_TO=docker://5.161.91.120:31234
6 declare -a images=(moqui-jdbc-drivers moqui-app moqui-jdbc-drivers)
7
8 _build() {
9 for image in "${images[@]}"; do
10 docker build -f Dockerfile --tag "${image}:${TAG}" --target "${image}" "${APP}"
11 done
12 }
13
14 _push() {
15 for image in "${images[@]}"; do
16 skopeo copy --dest-tls-verify=false "docker-daemon:${image}:${TAG}" "${PUSH_TO}/${image}:${TAG}"
17 done
18 }
19
20 case "$1" in
21 (build)
22 _build
23 ;;
24 (push)
25 _push
26 ;;
27 ("")
28 _build
29 _push
30 ;;
31 esac
32
1 apiVersion: elasticsearch.k8s.elastic.co/v1
2 kind: Elasticsearch
3 metadata:
4 name: moqui
5 spec:
6 version: 8.2.3
7 nodeSets:
8 - name: default
9 count: 2
10 config:
11 node.store.allow_mmap: false
12 ---
13 apiVersion: kibana.k8s.elastic.co/v1
14 kind: Kibana
15 metadata:
16 name: moqui
17 spec:
18 version: 8.2.3
19 count: 1
20 elasticsearchRef:
21 name: moqui
22 ---
23
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./elasticsearch.yaml
6
1 #!/bin/sh
2
3 cp -a /usr/share/java/postgresql* /mnt/jdbc-drivers
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./moqui.yaml
6
7 configMapGenerator:
8 - name: moqui-scripts
9 files:
10 - ./pg_isready
11 - ./copy-jdbc-drivers
12 options:
13 disableNameSuffixHash: true
14
1 ---
2 apiVersion: v1
3 kind: ConfigMap
4 metadata:
5 name: moqui
6 data:
7 instance_purpose: production
8 default_locale: en_US
9 default_time_zone: US/Central
10 database_time_zone: US/Central
11 entity_ds_db_conf: postgres
12 entity_ds_host: postgresql
13 entity_ds_port: "5432"
14 entity_ds_database: moqui
15 entity_ds_schema: public
16 _entity_add_missing_runtime: "true"
17 moqui_load_types: seed,seed-initial,install
18 ---
19 apiVersion: v1
20 kind: Secret
21 metadata:
22 name: moqui
23 stringData:
24 ---
25 apiVersion: v1
26 kind: PersistentVolumeClaim
27 metadata:
28 name: moqui-log
29 spec:
30 accessModes:
31 - ReadWriteOnce
32 resources:
33 requests:
34 storage: 10Gi
35 ---
36 apiVersion: v1
37 kind: PersistentVolumeClaim
38 metadata:
39 name: moqui-txlog
40 spec:
41 accessModes:
42 - ReadWriteOnce
43 resources:
44 requests:
45 storage: 2Gi
46 ---
47 apiVersion: v1
48 kind: PersistentVolumeClaim
49 metadata:
50 name: moqui-sessions
51 spec:
52 accessModes:
53 - ReadWriteOnce
54 resources:
55 requests:
56 storage: 2Gi
57 ---
58 apiVersion: v1
59 kind: Service
60 metadata:
61 name: moqui
62 spec:
63 type: ClusterIP
64 selector:
65 app: moqui
66 ports:
67 - name: http-moqui
68 protocol: TCP
69 port: 8080
70 targetPort: 8080
71 - name: http-hazelcast
72 protocol: TCP
73 port: 5701
74 targetPort: 5701
75 ---
76
77 apiVersion: apps/v1
78 kind: Deployment
79 metadata:
80 name: moqui
81 labels:
82 app: moqui
83 spec:
84 selector:
85 matchLabels:
86 app: moqui
87 template:
88 metadata:
89 labels:
90 app: moqui
91 spec:
92 restartPolicy: Always
93 securityContext:
94 runAsUser: 0
95 runAsGroup: 0
96
97 volumes:
98 - name: log
99 persistentVolumeClaim:
100 claimName: moqui-log
101 - name: txlog
102 persistentVolumeClaim:
103 claimName: moqui-txlog
104 - name: sessions
105 persistentVolumeClaim:
106 claimName: moqui-sessions
107 - name: scripts
108 configMap:
109 name: moqui-scripts
110 defaultMode: 0755
111 - name: lib
112 emptyDir: {}
113
114 initContainers:
115 - name: copy-jdbc-drivers
116 image: moqui-jdbc-drivers:latest
117 command: ["/scripts/copy-jdbc-drivers"]
118 volumeMounts:
119 - name: scripts
120 mountPath: /scripts
121 - name: lib
122 mountPath: /mnt/jdbc-drivers
123
124 containers:
125 - name: moqui
126 image: moqui-app:latest
127 envFrom:
128 - configMapRef:
129 name: moqui
130 - secretRef:
131 name: moqui
132 volumeMounts:
133 - name: lib
134 mountPath: /opt/moqui/runtime/lib
135 - name: log
136 mountPath: /opt/moqui/runtime/log
137 - name: txlog
138 mountPath: /opt/moqui/runtime/txlog
139 - name: sessions
140 mountPath: /opt/moqui/runtime/sessions
141
1 #!/bin/sh
2 set -ex
3
4 check_pg() {
5 pg_isready -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" -p 5432
6 }
7
8 while ! check_pg; do
9 echo "Waiting for database" 1>&2
10 sleep 1
11 count=5
12 while [ $count -gt 0 ] && ! check_pg; do
13 count=$(($count - 1))
14 sleep 1
15 done
16 done
1 apiVersion: kustomize.config.k8s.io/v1beta1
2 kind: Kustomization
3
4 resources:
5 - ./postgresql.yaml
6
1 ---
2 apiVersion: "acid.zalan.do/v1"
3 kind: postgresql
4 metadata:
5 name: moqui-postgresql
6 spec:
7 enableLogicalBackup: true
8 teamId: "moqui"
9 volume:
10 size: 1Gi
11 numberOfInstances: 2
12 users:
13 zalando: # database owner
14 - superuser
15 - createdb
16 moqui:
17 - login
18 databases:
19 moqui: moqui
20 postgresql:
21 version: "14"
22 ---
1 name: test
2 namespace: default
3 elasticsearch:
4 enabled: true
5 postgresql:
6 enabled: true
7 clone: {}
8 numberOfInstances: 2
9 volume:
10 size: 1Gi
11 version: "14"
12
1 environments:
2 {{ .Environment.Name }}:
3 missingFileHandler: Debug
4 values:
5 - environments/default-values.yaml
6 {{- if ne .Environment.Name "default" }}
7 - environments/{{ .Environment.Name }}-values.yaml
8 {{- end }}
9
10 ---
11 releases:
12 - name: {{ .Values.name }}-moqui-elasticsearch
13 condition: elasticsearch.enabled
14 chart: charts/elasticsearch
15 namespace: {{ .Values.namespace }}
16 values:
17 - namePrefix: {{ .Values.name }}-
18
19 - name: {{ .Values.name }}-moqui-postgresql
20 condition: postgresql.enabled
21 chart: charts/postgresql
22 namespace: {{ .Values.namespace }}
23 values:
24 - namePrefix: {{ .Values.name }}-
25 strategicMergePatches:
26 - apiVersion: acid.zalan.do/v1
27 kind: postgresql
28 metadata:
29 name: {{ .Values.name }}-moqui-postgresql
30 namespace: {{ .Values.namespace }}
31 spec:
32 teamId: {{ .Values.name }}-moqui
33 volume:
34 size: {{ .Values.postgresql.volume.size | quote }}
35 postgresql:
36 version: {{ .Values.postgresql.version | quote }}
37 {{- if .Values | get "postgresql.clone.uid" nil }}
38 clone:
39 {{ merge .Values.postgresql.clone ( dict "cluster" ( print .Values.name "-moqui-postgresql" ) ) | toYaml | nindent 12 }}
40 {{- end }}
41
42 - name: {{ .Values.name }}-moqui-app
43 chart: charts/moqui
44 namespace: {{ .Values.namespace }}
45 values:
46 - namePrefix: {{ .Values.name }}-
47 images:
48 - name: moqui-app
49 newName: localhost:31234/moqui-app
50 newTag: test-latest
51 - name: moqui-jdbc-drivers
52 newName: localhost:31234/moqui-jdbc-drivers
53 newTag: test-latest
54 strategicMergePatches:
55 - apiVersion: apps/v1
56 kind: Deployment
57 metadata:
58 name: {{ .Values.name }}-moqui
59 namespace: {{ .Values.namespace }}
60 labels:
61 app: {{ .Values.name }}-moqui
62 spec:
63 selector:
64 matchLabels:
65 app: {{ .Values.name }}-moqui
66 template:
67 metadata:
68 labels:
69 app: {{ .Values.name }}-moqui
70 spec:
71 restartPolicy: Always
72 securityContext:
73 runAsUser: 0
74 runAsGroup: 0
75
76 containers:
77 - name: moqui
78 env:
79 {{- if .Values.elasticsearch.enabled }}
80 - name: elasticsearch_url
81 value: https://{{ .Values.name }}-moqui-es-http:9200
82 - name: elasticsearch_user
83 value: elastic
84 - name: elasticsearch_password
85 valueFrom:
86 secretKeyRef:
87 name: {{ .Values.name }}-moqui-es-elastic-user
88 key: elastic
89 {{- end }}
90 {{- if .Values.postgresql.enabled }}
91 - name: entity_ds_db_conf
92 value: postgres
93 - name: entity_ds_host
94 value: {{ .Values.name }}-moqui-postgresql
95 - name: entity_ds_port
96 value: "5432"
97 - name: entity_ds_user
98 valueFrom:
99 secretKeyRef:
100 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
101 key: username
102 - name: entity_ds_password
103 valueFrom:
104 secretKeyRef:
105 name: moqui.{{ .Values.name }}-moqui-postgresql.credentials.postgresql.acid.zalan.do
106 key: password
107 - name: entity_ds_database
108 value: moqui
109 - name: entity_ds_schema
110 value: public
111 {{- end }}
112
113