underpost 2.8.6 → 2.8.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/extensions.json +36 -3
- package/.vscode/settings.json +2 -0
- package/CHANGELOG.md +24 -4
- package/Dockerfile +9 -10
- package/README.md +41 -2
- package/bin/build.js +2 -2
- package/bin/db.js +1 -0
- package/bin/deploy.js +1521 -130
- package/bin/file.js +8 -0
- package/bin/index.js +1 -218
- package/cli.md +530 -0
- package/conf.js +4 -0
- package/docker-compose.yml +1 -1
- package/jsdoc.json +1 -1
- package/manifests/deployment/adminer/deployment.yaml +32 -0
- package/manifests/deployment/adminer/kustomization.yaml +7 -0
- package/manifests/deployment/adminer/service.yaml +13 -0
- package/manifests/deployment/dd-template-development/deployment.yaml +167 -0
- package/manifests/deployment/dd-template-development/proxy.yaml +46 -0
- package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
- package/manifests/deployment/fastapi/backend-service.yml +19 -0
- package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
- package/manifests/deployment/fastapi/frontend-service.yml +15 -0
- package/manifests/deployment/fastapi/initial_data.sh +56 -0
- package/manifests/deployment/kafka/deployment.yaml +69 -0
- package/manifests/deployment/spark/spark-pi-py.yaml +21 -0
- package/manifests/envoy-service-nodeport.yaml +23 -0
- package/manifests/kubeadm-calico-config.yaml +119 -0
- package/manifests/kubelet-config.yaml +65 -0
- package/manifests/lxd/lxd-admin-profile.yaml +17 -0
- package/manifests/lxd/lxd-preseed.yaml +30 -0
- package/manifests/lxd/underpost-setup.sh +163 -0
- package/manifests/maas/lxd-preseed.yaml +32 -0
- package/manifests/maas/maas-setup.sh +82 -0
- package/manifests/mariadb/statefulset.yaml +2 -1
- package/manifests/mariadb/storage-class.yaml +10 -0
- package/manifests/mongodb/kustomization.yaml +1 -1
- package/manifests/mongodb/statefulset.yaml +12 -11
- package/manifests/mongodb/storage-class.yaml +9 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +3 -3
- package/manifests/mysql/kustomization.yaml +7 -0
- package/manifests/mysql/pv-pvc.yaml +27 -0
- package/manifests/mysql/statefulset.yaml +55 -0
- package/manifests/postgresql/configmap.yaml +9 -0
- package/manifests/postgresql/kustomization.yaml +10 -0
- package/manifests/postgresql/pv.yaml +15 -0
- package/manifests/postgresql/pvc.yaml +13 -0
- package/manifests/postgresql/service.yaml +10 -0
- package/manifests/postgresql/statefulset.yaml +37 -0
- package/manifests/valkey/service.yaml +3 -9
- package/manifests/valkey/statefulset.yaml +12 -13
- package/package.json +3 -9
- package/src/api/default/default.service.js +1 -1
- package/src/api/user/user.service.js +14 -11
- package/src/cli/baremetal.js +60 -0
- package/src/cli/cluster.js +551 -65
- package/src/cli/cron.js +39 -8
- package/src/cli/db.js +20 -10
- package/src/cli/deploy.js +288 -86
- package/src/cli/env.js +10 -4
- package/src/cli/fs.js +21 -9
- package/src/cli/image.js +116 -124
- package/src/cli/index.js +319 -0
- package/src/cli/lxd.js +395 -0
- package/src/cli/monitor.js +236 -0
- package/src/cli/repository.js +14 -8
- package/src/client/components/core/Account.js +28 -24
- package/src/client/components/core/Blockchain.js +1 -1
- package/src/client/components/core/CalendarCore.js +14 -84
- package/src/client/components/core/CommonJs.js +2 -1
- package/src/client/components/core/Css.js +0 -1
- package/src/client/components/core/CssCore.js +10 -2
- package/src/client/components/core/Docs.js +1 -1
- package/src/client/components/core/EventsUI.js +3 -3
- package/src/client/components/core/FileExplorer.js +86 -78
- package/src/client/components/core/JoyStick.js +2 -2
- package/src/client/components/core/LoadingAnimation.js +1 -17
- package/src/client/components/core/LogIn.js +3 -3
- package/src/client/components/core/LogOut.js +1 -1
- package/src/client/components/core/Modal.js +14 -8
- package/src/client/components/core/Panel.js +19 -61
- package/src/client/components/core/PanelForm.js +13 -22
- package/src/client/components/core/Recover.js +3 -3
- package/src/client/components/core/RichText.js +1 -11
- package/src/client/components/core/Router.js +3 -1
- package/src/client/components/core/SignUp.js +2 -2
- package/src/client/components/default/RoutesDefault.js +3 -2
- package/src/client/services/default/default.management.js +45 -38
- package/src/client/ssr/Render.js +2 -0
- package/src/index.js +34 -2
- package/src/mailer/MailerProvider.js +3 -0
- package/src/runtime/lampp/Dockerfile +65 -0
- package/src/server/client-build.js +13 -0
- package/src/server/conf.js +151 -1
- package/src/server/dns.js +56 -18
- package/src/server/json-schema.js +77 -0
- package/src/server/logger.js +3 -3
- package/src/server/network.js +7 -122
- package/src/server/peer.js +2 -2
- package/src/server/proxy.js +4 -4
- package/src/server/runtime.js +24 -11
- package/src/server/start.js +122 -0
- package/src/server/valkey.js +27 -13
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
apiVersion: v1
|
|
2
|
+
kind: Service
|
|
3
|
+
metadata:
|
|
4
|
+
name: mysql
|
|
5
|
+
labels:
|
|
6
|
+
app: mysql
|
|
7
|
+
spec:
|
|
8
|
+
ports:
|
|
9
|
+
- port: 3306
|
|
10
|
+
name: mysql
|
|
11
|
+
selector:
|
|
12
|
+
app: mysql
|
|
13
|
+
clusterIP: None
|
|
14
|
+
---
|
|
15
|
+
apiVersion: apps/v1
|
|
16
|
+
kind: StatefulSet
|
|
17
|
+
metadata:
|
|
18
|
+
name: mysql
|
|
19
|
+
spec:
|
|
20
|
+
serviceName: "mysql"
|
|
21
|
+
selector:
|
|
22
|
+
matchLabels:
|
|
23
|
+
app: mysql
|
|
24
|
+
replicas: 1
|
|
25
|
+
template:
|
|
26
|
+
metadata:
|
|
27
|
+
labels:
|
|
28
|
+
app: mysql
|
|
29
|
+
spec:
|
|
30
|
+
containers:
|
|
31
|
+
- image: mysql:9
|
|
32
|
+
name: mysql
|
|
33
|
+
env:
|
|
34
|
+
- name: MYSQL_ROOT_PASSWORD
|
|
35
|
+
valueFrom:
|
|
36
|
+
secretKeyRef:
|
|
37
|
+
name: mysql-secret
|
|
38
|
+
key: password
|
|
39
|
+
ports:
|
|
40
|
+
- containerPort: 3306
|
|
41
|
+
name: mysql
|
|
42
|
+
volumeMounts:
|
|
43
|
+
- name: mysql-persistent-storage
|
|
44
|
+
mountPath: /var/lib/mysql
|
|
45
|
+
subPath: mysql
|
|
46
|
+
volumeClaimTemplates:
|
|
47
|
+
- metadata:
|
|
48
|
+
name: mysql-persistent-storage
|
|
49
|
+
spec:
|
|
50
|
+
storageClassName: manual
|
|
51
|
+
accessModes:
|
|
52
|
+
- ReadWriteOnce
|
|
53
|
+
resources:
|
|
54
|
+
requests:
|
|
55
|
+
storage: 20Gi
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
kind: PersistentVolume
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
metadata:
|
|
4
|
+
name: postgres-pv-volume
|
|
5
|
+
labels:
|
|
6
|
+
type: local
|
|
7
|
+
app: postgres
|
|
8
|
+
spec:
|
|
9
|
+
storageClassName: manual
|
|
10
|
+
capacity:
|
|
11
|
+
storage: 5Gi
|
|
12
|
+
accessModes:
|
|
13
|
+
- ReadWriteMany
|
|
14
|
+
hostPath:
|
|
15
|
+
path: '/mnt/data'
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
apiVersion: apps/v1
|
|
2
|
+
kind: StatefulSet
|
|
3
|
+
metadata:
|
|
4
|
+
name: postgres
|
|
5
|
+
spec:
|
|
6
|
+
serviceName: postgres
|
|
7
|
+
replicas: 1
|
|
8
|
+
selector:
|
|
9
|
+
matchLabels:
|
|
10
|
+
app: postgres
|
|
11
|
+
template:
|
|
12
|
+
metadata:
|
|
13
|
+
labels:
|
|
14
|
+
app: postgres
|
|
15
|
+
spec:
|
|
16
|
+
containers:
|
|
17
|
+
- name: postgres
|
|
18
|
+
image: postgres:latest
|
|
19
|
+
imagePullPolicy: Never
|
|
20
|
+
ports:
|
|
21
|
+
- containerPort: 5432
|
|
22
|
+
envFrom:
|
|
23
|
+
- configMapRef:
|
|
24
|
+
name: postgres-config
|
|
25
|
+
env:
|
|
26
|
+
- name: POSTGRES_PASSWORD
|
|
27
|
+
valueFrom:
|
|
28
|
+
secretKeyRef:
|
|
29
|
+
name: postgres-secret
|
|
30
|
+
key: password
|
|
31
|
+
volumeMounts:
|
|
32
|
+
- mountPath: /var/lib/postgresql/data
|
|
33
|
+
name: postgredb
|
|
34
|
+
volumes:
|
|
35
|
+
- name: postgredb
|
|
36
|
+
persistentVolumeClaim:
|
|
37
|
+
claimName: postgres-pv-claim
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
---
|
|
2
1
|
apiVersion: v1
|
|
3
2
|
kind: Service
|
|
4
3
|
metadata:
|
|
5
|
-
name: service
|
|
4
|
+
name: valkey-service
|
|
6
5
|
namespace: default
|
|
7
6
|
spec:
|
|
7
|
+
selector:
|
|
8
|
+
app: valkey-service
|
|
8
9
|
ports:
|
|
9
10
|
- port: 6379
|
|
10
11
|
targetPort: 6379
|
|
11
|
-
selector:
|
|
12
|
-
app: service-valkey
|
|
13
|
-
ipFamilyPolicy: PreferDualStack
|
|
14
|
-
ipFamilies:
|
|
15
|
-
- IPv4
|
|
16
|
-
# - IPv6
|
|
17
|
-
type: ClusterIP
|
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
---
|
|
2
1
|
apiVersion: apps/v1
|
|
3
2
|
kind: StatefulSet
|
|
4
3
|
metadata:
|
|
5
|
-
name: service
|
|
4
|
+
name: valkey-service
|
|
6
5
|
namespace: default
|
|
7
6
|
spec:
|
|
8
|
-
serviceName: service
|
|
7
|
+
serviceName: valkey-service
|
|
9
8
|
replicas: 1
|
|
10
9
|
selector:
|
|
11
10
|
matchLabels:
|
|
12
|
-
app: service
|
|
11
|
+
app: valkey-service
|
|
13
12
|
template:
|
|
14
13
|
metadata:
|
|
15
14
|
labels:
|
|
16
|
-
app: service
|
|
15
|
+
app: valkey-service
|
|
17
16
|
spec:
|
|
17
|
+
automountServiceAccountToken: false
|
|
18
18
|
containers:
|
|
19
|
-
- name: service
|
|
19
|
+
- name: valkey-service
|
|
20
20
|
image: docker.io/valkey/valkey:latest
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
imagePullPolicy: IfNotPresent
|
|
22
|
+
command: ["valkey-server"]
|
|
23
|
+
args: ["--port", "6379"]
|
|
24
24
|
ports:
|
|
25
25
|
- containerPort: 6379
|
|
26
26
|
startupProbe:
|
|
27
27
|
tcpSocket:
|
|
28
28
|
port: 6379
|
|
29
|
-
failureThreshold: 30
|
|
30
29
|
periodSeconds: 5
|
|
31
30
|
timeoutSeconds: 5
|
|
31
|
+
failureThreshold: 30
|
|
32
32
|
livenessProbe:
|
|
33
33
|
tcpSocket:
|
|
34
34
|
port: 6379
|
|
35
|
-
|
|
35
|
+
initialDelaySeconds: 10
|
|
36
36
|
periodSeconds: 30
|
|
37
37
|
timeoutSeconds: 5
|
|
38
|
-
|
|
39
|
-
automountServiceAccountToken: false
|
|
38
|
+
failureThreshold: 2
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.8",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"dev": "env-cmd -f .env.development node src/client.dev default",
|
|
12
12
|
"dev-img": "env-cmd -f .env.development node src/server",
|
|
13
13
|
"prod-img": "env-cmd -f .env.production node src/server",
|
|
14
|
+
"monitor": "pm2 start bin/deploy.js --name monitor -- monitor",
|
|
14
15
|
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
15
16
|
"dev-client": "env-cmd -f .env.development node src/client.dev",
|
|
16
17
|
"proxy": "node src/proxy proxy",
|
|
@@ -69,7 +70,6 @@
|
|
|
69
70
|
"cors": "^2.8.5",
|
|
70
71
|
"d3": "^7.9.0",
|
|
71
72
|
"dotenv": "^16.3.1",
|
|
72
|
-
"easy-json-schema": "^0.0.2-beta",
|
|
73
73
|
"easymde": "^2.18.0",
|
|
74
74
|
"env-cmd": "^10.1.0",
|
|
75
75
|
"express": "^4.18.2",
|
|
@@ -119,13 +119,7 @@
|
|
|
119
119
|
"vanilla-jsoneditor": "^2.3.2",
|
|
120
120
|
"winston": "^3.11.0"
|
|
121
121
|
},
|
|
122
|
-
"devDependencies": {
|
|
123
|
-
"clean-jsdoc-theme": "^4.3.0",
|
|
124
|
-
"easy-json-schema": "^0.0.2-beta",
|
|
125
|
-
"mocha": "^10.8.2",
|
|
126
|
-
"plantuml": "^0.0.2",
|
|
127
|
-
"swagger-autogen": "^2.23.7"
|
|
128
|
-
},
|
|
122
|
+
"devDependencies": {},
|
|
129
123
|
"publishConfig": {
|
|
130
124
|
"provenance": true,
|
|
131
125
|
"access": "public",
|
|
@@ -24,7 +24,7 @@ const DefaultService = {
|
|
|
24
24
|
/** @type {import('./default.model.js').DefaultModel} */
|
|
25
25
|
const Default = DataBaseProvider.instance[`${options.host}${options.path}`].mongoose.models.Default;
|
|
26
26
|
if (req.params.id) return await Default.findByIdAndDelete(req.params.id);
|
|
27
|
-
else return await
|
|
27
|
+
else return await Default.deleteMany();
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -225,8 +225,8 @@ const UserService = {
|
|
|
225
225
|
} else throw new Error('invalid email or password');
|
|
226
226
|
|
|
227
227
|
case 'guest': {
|
|
228
|
-
const user = await ValkeyAPI.valkeyObjectFactory('user'
|
|
229
|
-
await ValkeyAPI.setValkeyObject(user.email, user);
|
|
228
|
+
const user = await ValkeyAPI.valkeyObjectFactory(options, 'user');
|
|
229
|
+
await ValkeyAPI.setValkeyObject(options, user.email, user);
|
|
230
230
|
return {
|
|
231
231
|
token: hashJWT({ user: UserDto.auth.payload(user) }),
|
|
232
232
|
user: selectDtoFactory(user, UserDto.select.get()),
|
|
@@ -325,15 +325,18 @@ const UserService = {
|
|
|
325
325
|
return await User.find().select(UserDto.select.getAll());
|
|
326
326
|
|
|
327
327
|
case 'auth': {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
328
|
+
let user;
|
|
329
|
+
if (req.auth.user._id.match('guest')) {
|
|
330
|
+
user = await ValkeyAPI.getValkeyObject(options, req.auth.user.email);
|
|
331
|
+
if (!user) throw new Error('guest user expired');
|
|
332
|
+
} else
|
|
333
|
+
user = await User.findOne({
|
|
334
|
+
_id: req.auth.user._id,
|
|
335
|
+
});
|
|
333
336
|
|
|
334
337
|
const file = await File.findOne({ _id: user.profileImageId });
|
|
335
338
|
|
|
336
|
-
if (!file && !(await ValkeyAPI.getValkeyObject(req.auth.user.email))) {
|
|
339
|
+
if (!file && !(await ValkeyAPI.getValkeyObject(options, req.auth.user.email))) {
|
|
337
340
|
await User.findByIdAndUpdate(
|
|
338
341
|
user._id,
|
|
339
342
|
{ profileImageId: await getDefaultProfileImageId(File) },
|
|
@@ -342,8 +345,8 @@ const UserService = {
|
|
|
342
345
|
},
|
|
343
346
|
);
|
|
344
347
|
}
|
|
345
|
-
return (await ValkeyAPI.getValkeyObject(req.auth.user.email))
|
|
346
|
-
? selectDtoFactory(await ValkeyAPI.getValkeyObject(req.auth.user.email), UserDto.select.get())
|
|
348
|
+
return (await ValkeyAPI.getValkeyObject(options, req.auth.user.email))
|
|
349
|
+
? selectDtoFactory(await ValkeyAPI.getValkeyObject(options, req.auth.user.email), UserDto.select.get())
|
|
347
350
|
: await User.findOne({
|
|
348
351
|
_id: req.auth.user._id,
|
|
349
352
|
}).select(UserDto.select.get());
|
|
@@ -378,7 +381,7 @@ const UserService = {
|
|
|
378
381
|
switch (user.role) {
|
|
379
382
|
case 'admin': {
|
|
380
383
|
if (req.params.id) return await User.findByIdAndDelete(req.params.id);
|
|
381
|
-
else return await
|
|
384
|
+
else return await User.deleteMany();
|
|
382
385
|
}
|
|
383
386
|
default:
|
|
384
387
|
if (req.auth.user._id !== req.params.id) throw new Error(`Invalid token user id`);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
|
|
2
|
+
import { shellExec } from '../server/process.js';
|
|
3
|
+
import dotenv from 'dotenv';
|
|
4
|
+
class UnderpostBaremetal {
|
|
5
|
+
static API = {
|
|
6
|
+
callback(
|
|
7
|
+
options = {
|
|
8
|
+
dev: false,
|
|
9
|
+
controlServerInstall: false,
|
|
10
|
+
controlServerInitDb: false,
|
|
11
|
+
controlServerInit: false,
|
|
12
|
+
controlServerUninstall: false,
|
|
13
|
+
controlServerStop: false,
|
|
14
|
+
controlServerStart: false,
|
|
15
|
+
},
|
|
16
|
+
) {
|
|
17
|
+
dotenv.config({ path: `${getUnderpostRootPath()}/.env`, override: true });
|
|
18
|
+
const npmRoot = getNpmRootPath();
|
|
19
|
+
const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
|
|
20
|
+
const dbProviderId = 'postgresql-14';
|
|
21
|
+
if (options.controlServerUninstall === true) {
|
|
22
|
+
// Stop MAAS services
|
|
23
|
+
shellExec(`sudo systemctl stop maas.pebble || true`);
|
|
24
|
+
shellExec(`sudo snap stop maas`);
|
|
25
|
+
shellExec(`sudo snap remove maas --purge || true`);
|
|
26
|
+
|
|
27
|
+
// Remove Snap residual data
|
|
28
|
+
shellExec(`sudo rm -rf /var/snap/maas`);
|
|
29
|
+
shellExec(`sudo rm -rf ~/snap/maas`);
|
|
30
|
+
|
|
31
|
+
// Remove MAAS config and data directories
|
|
32
|
+
shellExec(`sudo rm -rf /etc/maas`);
|
|
33
|
+
shellExec(`sudo rm -rf /var/lib/maas`);
|
|
34
|
+
shellExec(`sudo rm -rf /var/log/maas`);
|
|
35
|
+
}
|
|
36
|
+
if (options.controlServerStart === true) {
|
|
37
|
+
shellExec(`sudo snap restart maas`);
|
|
38
|
+
}
|
|
39
|
+
if (options.controlServerStop === true) {
|
|
40
|
+
shellExec(`sudo snap stop maas`);
|
|
41
|
+
}
|
|
42
|
+
if (options.controlServerInitDb === true) {
|
|
43
|
+
shellExec(`node ${underpostRoot}/bin/deploy ${dbProviderId} install`);
|
|
44
|
+
shellExec(
|
|
45
|
+
`node ${underpostRoot}/bin/deploy pg-drop-db ${process.env.DB_PG_MAAS_NAME} ${process.env.DB_PG_MAAS_USER}`,
|
|
46
|
+
);
|
|
47
|
+
shellExec(`node ${underpostRoot}/bin/deploy maas db`);
|
|
48
|
+
}
|
|
49
|
+
if (options.controlServerInstall === true) {
|
|
50
|
+
shellExec(`chmod +x ${underpostRoot}/manifests/maas/maas-setup.sh`);
|
|
51
|
+
shellExec(`${underpostRoot}/manifests/maas/maas-setup.sh`);
|
|
52
|
+
}
|
|
53
|
+
if (options.controlServerInit === true) {
|
|
54
|
+
shellExec(`node ${underpostRoot}/bin/deploy maas reset`);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default UnderpostBaremetal;
|