arui-scripts 13.2.1 → 13.3.0-feat-fast-docker-build.2
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/CHANGELOG.md +14 -0
- package/build/bin/index.js +1 -0
- package/build/commands/docker-build-fast/index.d.ts +1 -0
- package/build/commands/docker-build-fast/index.js +91 -0
- package/build/commands/util/exec.js +1 -0
- package/build/configs/util/apply-overrides.d.ts +1 -0
- package/build/templates/dockerfile-fast.template.d.ts +2 -0
- package/build/templates/dockerfile-fast.template.js +31 -0
- package/build/tsconfig-local.tsbuildinfo +41 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [13.3.0-feat-fast-docker-build.2](https://git.moscow.alfaintra.net/ef/arui-scripts/compare/v13.3.0-feat-fast-docker-build.1...v13.3.0-feat-fast-docker-build.2) (2022-12-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **docker-fast:** don't build anything inside of container ([8f255bd](https://git.moscow.alfaintra.net/ef/arui-scripts/commit/8f255bd8fb9818a8498bddee71ef83ce4a7ba11b))
|
|
7
|
+
|
|
8
|
+
# [13.3.0-feat-fast-docker-build.1](https://git.moscow.alfaintra.net/ef/arui-scripts/compare/v13.2.1...v13.3.0-feat-fast-docker-build.1) (2022-12-05)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **docker:** add fast docker build command ([82301a8](https://git.moscow.alfaintra.net/ef/arui-scripts/commit/82301a8d912476fd5516f94083ccd7c5363f4509))
|
|
14
|
+
|
|
1
15
|
## [13.2.1](https://git.moscow.alfaintra.net/ef/arui-scripts/compare/v13.2.0...v13.2.1) (2022-12-05)
|
|
2
16
|
|
|
3
17
|
|
package/build/bin/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
+
const app_configs_1 = __importDefault(require("../../configs/app-configs"));
|
|
18
|
+
const dockerfile_fast_template_1 = __importDefault(require("../../templates/dockerfile-fast.template"));
|
|
19
|
+
const nginx_conf_template_1 = __importDefault(require("../../templates/nginx.conf.template"));
|
|
20
|
+
const start_template_1 = __importDefault(require("../../templates/start.template"));
|
|
21
|
+
const exec_1 = __importDefault(require("../util/exec"));
|
|
22
|
+
let imageVersion = app_configs_1.default.version;
|
|
23
|
+
let imageName = app_configs_1.default.name;
|
|
24
|
+
let dockerRegistry = app_configs_1.default.dockerRegistry;
|
|
25
|
+
const commandLineArguments = process.argv.slice(3);
|
|
26
|
+
commandLineArguments.forEach(arg => {
|
|
27
|
+
let [argName, argValue] = arg.split('=');
|
|
28
|
+
argName = argName.toLowerCase().trim();
|
|
29
|
+
argValue = argValue ? argValue.trim() : '';
|
|
30
|
+
switch (argName) {
|
|
31
|
+
case 'version':
|
|
32
|
+
imageVersion = argValue;
|
|
33
|
+
break;
|
|
34
|
+
case 'name':
|
|
35
|
+
imageName = argValue;
|
|
36
|
+
break;
|
|
37
|
+
case 'registry':
|
|
38
|
+
dockerRegistry = argValue;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
console.warn(`Unknown argument ${argName}`);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const tempDirName = '.docker-build';
|
|
45
|
+
const pathToTempDir = path_1.default.join(app_configs_1.default.cwd, tempDirName);
|
|
46
|
+
const imageFullName = `${dockerRegistry ? `${dockerRegistry}/` : ''}${imageName}:${imageVersion}`;
|
|
47
|
+
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
+
try {
|
|
49
|
+
console.log(`Build docker image ${imageFullName}`);
|
|
50
|
+
console.time('Total time');
|
|
51
|
+
console.time('Setting up time');
|
|
52
|
+
// create tmp directory for docker related files
|
|
53
|
+
// We need to copy it because we will remove this directory during build process
|
|
54
|
+
yield fs_extra_1.default.emptyDir(pathToTempDir);
|
|
55
|
+
const nginxConf = app_configs_1.default.localNginxConf
|
|
56
|
+
? yield fs_extra_1.default.readFile(app_configs_1.default.localNginxConf, 'utf8')
|
|
57
|
+
: nginx_conf_template_1.default;
|
|
58
|
+
const dockerfile = app_configs_1.default.localDockerfile
|
|
59
|
+
? yield fs_extra_1.default.readFile(app_configs_1.default.localDockerfile, 'utf8')
|
|
60
|
+
: dockerfile_fast_template_1.default;
|
|
61
|
+
yield Promise.all([
|
|
62
|
+
fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'Dockerfile'), dockerfile, 'utf8'),
|
|
63
|
+
fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'nginx.conf'), nginxConf, 'utf8'),
|
|
64
|
+
fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'start.sh'), start_template_1.default, { encoding: 'utf8', mode: 0o555 }),
|
|
65
|
+
fs_extra_1.default.remove(app_configs_1.default.buildPath),
|
|
66
|
+
]);
|
|
67
|
+
console.timeEnd('Setting up time');
|
|
68
|
+
console.time('Build docker image time');
|
|
69
|
+
yield exec_1.default(`docker build -f "./${tempDirName}/Dockerfile" \\
|
|
70
|
+
--build-arg START_SH_LOCATION="./${tempDirName}/start.sh" \\
|
|
71
|
+
--build-arg NGINX_CONF_LOCATION="./${tempDirName}/nginx.conf" -t ${imageFullName} .`);
|
|
72
|
+
console.timeEnd('Build docker image time');
|
|
73
|
+
console.time('Cleanup time');
|
|
74
|
+
// remove temp directory
|
|
75
|
+
yield fs_extra_1.default.remove(pathToTempDir);
|
|
76
|
+
// guard against pushing the image during tests
|
|
77
|
+
if (!app_configs_1.default.debug) {
|
|
78
|
+
yield exec_1.default(`docker push ${imageFullName}`);
|
|
79
|
+
}
|
|
80
|
+
console.timeEnd('Cleanup time');
|
|
81
|
+
console.timeEnd('Total time');
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
yield fs_extra_1.default.remove(pathToTempDir);
|
|
85
|
+
console.error('Error during docker-build.');
|
|
86
|
+
if (app_configs_1.default.debug) {
|
|
87
|
+
console.error(err);
|
|
88
|
+
}
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}))();
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const shelljs_1 = __importDefault(require("shelljs"));
|
|
7
7
|
function exec(command) {
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
|
+
console.log(`Executing command: ${command}`);
|
|
9
10
|
shelljs_1.default.exec(command, (code) => {
|
|
10
11
|
if (code === 0) {
|
|
11
12
|
return resolve(code);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const app_configs_1 = __importDefault(require("../configs/app-configs"));
|
|
7
|
+
const apply_overrides_1 = __importDefault(require("../configs/util/apply-overrides"));
|
|
8
|
+
const dockerfileTemplate = `
|
|
9
|
+
FROM ${app_configs_1.default.baseDockerImage}
|
|
10
|
+
ARG START_SH_LOCATION
|
|
11
|
+
ARG NGINX_CONF_LOCATION
|
|
12
|
+
|
|
13
|
+
USER nginx
|
|
14
|
+
WORKDIR /src
|
|
15
|
+
RUN mkdir -p /var/lib/nginx && \
|
|
16
|
+
chown -R nginx:nginx /var/lib/nginx && \
|
|
17
|
+
chown -R nginx:nginx /var/log/nginx && \
|
|
18
|
+
chown -R nginx:nginx /etc/nginx/conf.d
|
|
19
|
+
|
|
20
|
+
RUN touch /var/run/nginx.pid && \
|
|
21
|
+
chown -R nginx:nginx /var/run/nginx.pid
|
|
22
|
+
|
|
23
|
+
ADD $START_SH_LOCATION /src/start.sh
|
|
24
|
+
ADD $NGINX_CONF_LOCATION /src/nginx.conf
|
|
25
|
+
ADD --chown=nginx:nginx yarn.lock /src/yarn.lock
|
|
26
|
+
ADD --chown=nginx:nginx package.json /src/package.json
|
|
27
|
+
RUN yarn install --production --ignore-optional --frozen-lockfile --ignore-scripts --prefer-offline && \\
|
|
28
|
+
yarn cache clean
|
|
29
|
+
ADD --chown=nginx:nginx . /src
|
|
30
|
+
`;
|
|
31
|
+
exports.default = apply_overrides_1.default('Dockerfile-fast', dockerfileTemplate);
|
|
@@ -742,8 +742,8 @@
|
|
|
742
742
|
"affectsGlobalScope": false
|
|
743
743
|
},
|
|
744
744
|
"../src/configs/util/apply-overrides.ts": {
|
|
745
|
-
"version": "
|
|
746
|
-
"signature": "
|
|
745
|
+
"version": "6ffec1ba6cb9eee767269fe0000dfe6e30a6d116c0cf78ce93367cb80de8722e",
|
|
746
|
+
"signature": "26844f518d1d8e3f8833e01de394c10e5e878ebf3b11b7d8ffa0e8c52add4c5a",
|
|
747
747
|
"affectsGlobalScope": false
|
|
748
748
|
},
|
|
749
749
|
"../src/index.ts": {
|
|
@@ -757,7 +757,7 @@
|
|
|
757
757
|
"affectsGlobalScope": false
|
|
758
758
|
},
|
|
759
759
|
"../src/bin/index.ts": {
|
|
760
|
-
"version": "
|
|
760
|
+
"version": "dcaf4446fc2d9ff375b12ff54daeff02f2f9396ee13aecb05710bb3bbe0b8677",
|
|
761
761
|
"signature": "2ac79bb3486c40467f86c9c30cc50e06ab428b7308602e4827e49a09ecede366",
|
|
762
762
|
"affectsGlobalScope": true
|
|
763
763
|
},
|
|
@@ -792,7 +792,7 @@
|
|
|
792
792
|
"affectsGlobalScope": false
|
|
793
793
|
},
|
|
794
794
|
"../src/commands/util/exec.ts": {
|
|
795
|
-
"version": "
|
|
795
|
+
"version": "0eecf1a11c1427a78dd57a74d00dac418979623ae54e5e678545c03f23cde119",
|
|
796
796
|
"signature": "cbab75ff7efc7cca9f9a2dbcff2daf293b8f2dc4255b4bf2d6cd8f87d6ee7794",
|
|
797
797
|
"affectsGlobalScope": false
|
|
798
798
|
},
|
|
@@ -1331,6 +1331,16 @@
|
|
|
1331
1331
|
"signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881",
|
|
1332
1332
|
"affectsGlobalScope": false
|
|
1333
1333
|
},
|
|
1334
|
+
"../src/templates/dockerfile-fast.template.ts": {
|
|
1335
|
+
"version": "78b3651d2f51bcd4c24ccf00def5a2cf377cecc7044d529582b1319390d0fd3b",
|
|
1336
|
+
"signature": "0fffbf1a5f54522ff7b89592bab1cf72966d7bdc613d52b0087717fcfec14b29",
|
|
1337
|
+
"affectsGlobalScope": false
|
|
1338
|
+
},
|
|
1339
|
+
"../src/commands/docker-build-fast/index.ts": {
|
|
1340
|
+
"version": "f4a693ea311275f3493c35ef55079adbec1c1c24162c7c7f2c8c42e1cf9b758e",
|
|
1341
|
+
"signature": "8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881",
|
|
1342
|
+
"affectsGlobalScope": false
|
|
1343
|
+
},
|
|
1334
1344
|
"../src/commands/ensure-yarn/index.ts": {
|
|
1335
1345
|
"version": "aebd321455246c816849cb05ee9d873c31cb9732b1f2313763c7e776125b1209",
|
|
1336
1346
|
"signature": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
|
@@ -5798,6 +5808,20 @@
|
|
|
5798
5808
|
"../src/configs/app-configs/index.ts",
|
|
5799
5809
|
"../src/configs/webpack.client.prod.ts"
|
|
5800
5810
|
],
|
|
5811
|
+
"../src/commands/docker-build-fast/index.ts": [
|
|
5812
|
+
"../../../node_modules/@types/fs-extra/index.d.ts",
|
|
5813
|
+
"../../../node_modules/@types/graceful-fs/index.d.ts",
|
|
5814
|
+
"../node_modules/@types/node/ts3.1/fs.d.ts",
|
|
5815
|
+
"../node_modules/@types/node/ts3.1/path.d.ts",
|
|
5816
|
+
"../node_modules/@types/node/ts3.1/util.d.ts",
|
|
5817
|
+
"../node_modules/@types/node/ts3.3/fs.d.ts",
|
|
5818
|
+
"../node_modules/@types/node/ts3.3/util.d.ts",
|
|
5819
|
+
"../src/commands/util/exec.ts",
|
|
5820
|
+
"../src/configs/app-configs/index.ts",
|
|
5821
|
+
"../src/templates/dockerfile-fast.template.ts",
|
|
5822
|
+
"../src/templates/nginx.conf.template.ts",
|
|
5823
|
+
"../src/templates/start.template.ts"
|
|
5824
|
+
],
|
|
5801
5825
|
"../src/commands/docker-build/index.ts": [
|
|
5802
5826
|
"../../../node_modules/@types/fs-extra/index.d.ts",
|
|
5803
5827
|
"../../../node_modules/@types/graceful-fs/index.d.ts",
|
|
@@ -6376,6 +6400,15 @@
|
|
|
6376
6400
|
"../node_modules/@types/node/ts3.3/fs.d.ts",
|
|
6377
6401
|
"../node_modules/@types/node/ts3.3/util.d.ts"
|
|
6378
6402
|
],
|
|
6403
|
+
"../src/templates/dockerfile-fast.template.ts": [
|
|
6404
|
+
"../../../node_modules/@types/graceful-fs/index.d.ts",
|
|
6405
|
+
"../node_modules/@types/node/ts3.1/fs.d.ts",
|
|
6406
|
+
"../node_modules/@types/node/ts3.1/util.d.ts",
|
|
6407
|
+
"../node_modules/@types/node/ts3.3/fs.d.ts",
|
|
6408
|
+
"../node_modules/@types/node/ts3.3/util.d.ts",
|
|
6409
|
+
"../src/configs/app-configs/index.ts",
|
|
6410
|
+
"../src/configs/util/apply-overrides.ts"
|
|
6411
|
+
],
|
|
6379
6412
|
"../src/templates/dockerfile.template.ts": [
|
|
6380
6413
|
"../../../node_modules/@types/graceful-fs/index.d.ts",
|
|
6381
6414
|
"../node_modules/@types/node/ts3.1/fs.d.ts",
|
|
@@ -9918,8 +9951,8 @@
|
|
|
9918
9951
|
"../../../.yarn/__virtual__/webpack-virtual-321c743fbb/0/cache/webpack-npm-5.59.0-c550703883-3ccda49eaf.zip/node_modules/webpack/types.d.ts"
|
|
9919
9952
|
],
|
|
9920
9953
|
"../src/configs/util/apply-overrides.ts": [
|
|
9921
|
-
"
|
|
9922
|
-
"
|
|
9954
|
+
"../../../node_modules/@types/webpack-dev-server/index.d.ts",
|
|
9955
|
+
"../../../node_modules/webpack/types.d.ts",
|
|
9923
9956
|
"../src/configs/app-configs/types.ts"
|
|
9924
9957
|
],
|
|
9925
9958
|
"../src/configs/util/get-polyfills.ts": [
|
|
@@ -10338,6 +10371,7 @@
|
|
|
10338
10371
|
"../src/commands/build/index.ts",
|
|
10339
10372
|
"../src/commands/build/server.ts",
|
|
10340
10373
|
"../src/commands/bundle-analyze/index.ts",
|
|
10374
|
+
"../src/commands/docker-build-fast/index.ts",
|
|
10341
10375
|
"../src/commands/docker-build/index.ts",
|
|
10342
10376
|
"../src/commands/ensure-yarn/index.ts",
|
|
10343
10377
|
"../src/commands/start/client.ts",
|
|
@@ -10395,6 +10429,7 @@
|
|
|
10395
10429
|
"../src/configs/webpack.server.prod.ts",
|
|
10396
10430
|
"../src/index.ts",
|
|
10397
10431
|
"../src/plugins/reload-server-webpack-plugin.js",
|
|
10432
|
+
"../src/templates/dockerfile-fast.template.ts",
|
|
10398
10433
|
"../src/templates/dockerfile.template.ts",
|
|
10399
10434
|
"../src/templates/nginx.conf.template.ts",
|
|
10400
10435
|
"../src/templates/start.template.ts",
|