underpost 2.8.612 → 2.8.621
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/bin/deploy.js +1 -1
- package/docker-compose.yml +1 -1
- package/package.json +1 -1
- package/src/cli/deploy.js +24 -14
- package/src/cli/env.js +8 -2
- package/src/cli/image.js +6 -22
- package/src/index.js +1 -1
package/bin/deploy.js
CHANGED
|
@@ -673,8 +673,8 @@ try {
|
|
|
673
673
|
}
|
|
674
674
|
|
|
675
675
|
case 'version-build': {
|
|
676
|
-
const newVersion = process.argv[3];
|
|
677
676
|
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
|
677
|
+
const newVersion = process.argv[3] ?? originPackageJson.version;
|
|
678
678
|
const { version } = originPackageJson;
|
|
679
679
|
originPackageJson.version = newVersion;
|
|
680
680
|
fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
package/src/cli/deploy.js
CHANGED
|
@@ -50,7 +50,17 @@ class UnderpostDeploy {
|
|
|
50
50
|
if (env === 'development') fs.mkdirSync(`./manifests/deployment/${deployId}-${env}`, { recursive: true });
|
|
51
51
|
|
|
52
52
|
logger.info('port range', { deployId, fromPort, toPort });
|
|
53
|
-
|
|
53
|
+
// const customImg = `underpost-engine:${version && typeof version === 'string' ? version : Underpost.version}`;
|
|
54
|
+
// lifecycle:
|
|
55
|
+
// postStart:
|
|
56
|
+
// exec:
|
|
57
|
+
// command:
|
|
58
|
+
// - /bin/sh
|
|
59
|
+
// - -c
|
|
60
|
+
// - >
|
|
61
|
+
// sleep 20 &&
|
|
62
|
+
// npm install -g underpost &&
|
|
63
|
+
// underpost secret underpost --create-from-file /etc/config/.env.${env}
|
|
54
64
|
const deploymentYamlParts = `apiVersion: apps/v1
|
|
55
65
|
kind: Deployment
|
|
56
66
|
metadata:
|
|
@@ -69,19 +79,19 @@ spec:
|
|
|
69
79
|
spec:
|
|
70
80
|
containers:
|
|
71
81
|
- name: ${deployId}-${env}
|
|
72
|
-
image: localhost/underpost
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
image: localhost/debian:underpost
|
|
83
|
+
command:
|
|
84
|
+
- /bin/sh
|
|
85
|
+
- -c
|
|
86
|
+
- >
|
|
87
|
+
npm install -g npm@11.2.0 &&
|
|
88
|
+
npm config delete proxy &&
|
|
89
|
+
npm config delete http-proxy &&
|
|
90
|
+
npm config delete https-proxy &&
|
|
91
|
+
npm config set registry http://registry.npmjs.org/ &&
|
|
92
|
+
npm install --unsafe-perm --ignore-scripts -g underpost &&
|
|
93
|
+
underpost secret underpost --create-from-file /etc/config/.env.${env} &&
|
|
94
|
+
underpost dockerfile-node-script --build --run ${deployId} ${env}
|
|
85
95
|
volumeMounts:
|
|
86
96
|
- name: config-volume
|
|
87
97
|
mountPath: /etc/config
|
package/src/cli/env.js
CHANGED
|
@@ -28,7 +28,10 @@ class UnderpostRootEnv {
|
|
|
28
28
|
get(key) {
|
|
29
29
|
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
30
30
|
const envPath = `${exeRootPath}/.env`;
|
|
31
|
-
if (!fs.existsSync(envPath))
|
|
31
|
+
if (!fs.existsSync(envPath)) {
|
|
32
|
+
logger.error(`Unable to find underpost root environment`);
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
32
35
|
const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
33
36
|
logger.info(`${key}(${typeof env[key]})`, env[key]);
|
|
34
37
|
return env[key];
|
|
@@ -36,7 +39,10 @@ class UnderpostRootEnv {
|
|
|
36
39
|
list() {
|
|
37
40
|
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
38
41
|
const envPath = `${exeRootPath}/.env`;
|
|
39
|
-
if (!fs.existsSync(envPath))
|
|
42
|
+
if (!fs.existsSync(envPath)) {
|
|
43
|
+
logger.error(`Unable to find underpost root environment`);
|
|
44
|
+
return {};
|
|
45
|
+
}
|
|
40
46
|
const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
41
47
|
logger.info('underpost root', env);
|
|
42
48
|
return env;
|
package/src/cli/image.js
CHANGED
|
@@ -5,9 +5,12 @@ import dotenv from 'dotenv';
|
|
|
5
5
|
import { getNpmRootPath } from '../server/conf.js';
|
|
6
6
|
import { timer } from '../client/components/core/CommonJs.js';
|
|
7
7
|
import UnderpostRootEnv from './env.js';
|
|
8
|
+
import { loggerFactory } from '../server/logger.js';
|
|
8
9
|
|
|
9
10
|
dotenv.config();
|
|
10
11
|
|
|
12
|
+
const logger = loggerFactory(import.meta);
|
|
13
|
+
|
|
11
14
|
class UnderpostImage {
|
|
12
15
|
static API = {
|
|
13
16
|
dockerfile: {
|
|
@@ -23,7 +26,7 @@ class UnderpostImage {
|
|
|
23
26
|
const imgName = `${
|
|
24
27
|
options.imageName && typeof options.imageName === 'string' ? options.imageName : `${deployId}-${env}`
|
|
25
28
|
}:${
|
|
26
|
-
options.imageVersion && typeof options.
|
|
29
|
+
options.imageVersion && typeof options.imageVersion === 'string' ? options.imageVersion : Underpost.version
|
|
27
30
|
}`;
|
|
28
31
|
const podManImg = `localhost/${imgName}`;
|
|
29
32
|
const imagesStoragePath = `/images`;
|
|
@@ -52,18 +55,6 @@ class UnderpostImage {
|
|
|
52
55
|
shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
|
|
53
56
|
},
|
|
54
57
|
async script(deployId = 'default', env = 'development', options = { run: false, build: false }) {
|
|
55
|
-
if (deployId === 'service') {
|
|
56
|
-
const _deployId = UnderpostRootEnv.API.get('deploy-id');
|
|
57
|
-
const _env = UnderpostRootEnv.API.get('deploy-env');
|
|
58
|
-
process.env.GITHUB_TOKEN = UnderpostRootEnv.API.get('GITHUB_TOKEN');
|
|
59
|
-
if (_deployId && process.env.GITHUB_TOKEN) {
|
|
60
|
-
deployId = _deployId;
|
|
61
|
-
if (_env) env = _env;
|
|
62
|
-
} else {
|
|
63
|
-
await timer(30 * 1000);
|
|
64
|
-
return await UnderpostImage.API.dockerfile.script(deployId, env, options);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
58
|
if (options.build === true) {
|
|
68
59
|
const buildBasePath = `/home/dd`;
|
|
69
60
|
const repoName = `engine-${deployId.split('-')[1]}`;
|
|
@@ -72,19 +63,12 @@ class UnderpostImage {
|
|
|
72
63
|
shellExec(`cd ${buildBasePath}/engine && underpost clone underpostnet/${repoName}-private`);
|
|
73
64
|
shellExec(`cd ${buildBasePath}/engine && sudo mv ./${repoName}-private ./engine-private`);
|
|
74
65
|
shellCd(`${buildBasePath}/engine`);
|
|
75
|
-
shellExec(`
|
|
76
|
-
const itcScripts = fs.readdir('./engine-private/itc-scripts');
|
|
66
|
+
shellExec(`underpost install`);
|
|
67
|
+
const itcScripts = await fs.readdir('./engine-private/itc-scripts');
|
|
77
68
|
for (const itcScript of itcScripts)
|
|
78
69
|
if (itcScript.match(deployId)) shellExec(`node ./engine-private/itc-scripts/${itcScript}`);
|
|
79
70
|
}
|
|
80
71
|
switch (deployId) {
|
|
81
|
-
case 'dd-lampp':
|
|
82
|
-
{
|
|
83
|
-
const lamppPublicPath = '/xampp/htdocs/online';
|
|
84
|
-
shellExec(`sudo mkdir -p ${lamppPublicPath}`);
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
|
|
88
72
|
default:
|
|
89
73
|
{
|
|
90
74
|
{
|