@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.0
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/lib/commands/cli.js +2 -4
- package/lib/commands/execute.js +28 -3
- package/lib/commands/start.js +37 -15
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +65 -42
- package/lib/config/get-project-configuration.js +3 -1
- package/lib/config/index.js +10 -7
- package/lib/config/magento/required-php-extensions/index.js +29 -0
- package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
- package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
- package/lib/config/php/base-repo.js +3 -0
- package/lib/config/php/extensions/apcu.js +12 -0
- package/lib/config/php/extensions/bcmath.js +7 -0
- package/lib/config/php/extensions/curl.js +11 -0
- package/lib/config/php/extensions/gd.js +14 -0
- package/lib/config/php/extensions/index.js +18 -2
- package/lib/config/php/extensions/intl.js +10 -0
- package/lib/config/php/extensions/opcache.js +10 -0
- package/lib/config/php/extensions/pdo_mysql.js +7 -0
- package/lib/config/php/extensions/soap.js +10 -0
- package/lib/config/php/extensions/sodium.js +10 -0
- package/lib/config/php/extensions/xdebug.js +8 -5
- package/lib/config/php/extensions/xsl.js +10 -0
- package/lib/config/php/extensions/zip.js +10 -0
- package/lib/config/php/{releases → versions}/index.js +0 -0
- package/lib/config/php/versions/php-7.2.js +23 -0
- package/lib/config/php/versions/php-7.3.js +23 -0
- package/lib/config/php/versions/php-7.4.js +23 -0
- package/lib/config/php/versions/php-8.1.js +23 -0
- package/lib/config/php-config.js +8 -12
- package/lib/config/port-config.js +1 -5
- package/lib/config/templates/magentorc.template +3 -3
- package/lib/config/templates/php-fpm.template.conf +3 -3
- package/lib/config/templates/php.template.ini +12 -6
- package/lib/config/templates/ssl-terminator.template.conf +1 -1
- package/lib/config/templates/vscode-launch.template.json +3 -1
- package/lib/config/versions/magento-2.3.0.js +8 -2
- package/lib/config/versions/magento-2.3.1.js +8 -2
- package/lib/config/versions/magento-2.3.2-p1.js +44 -0
- package/lib/config/versions/magento-2.3.2-p2.js +8 -2
- package/lib/config/versions/magento-2.3.2.js +8 -2
- package/lib/config/versions/magento-2.3.3-p1.js +8 -2
- package/lib/config/versions/magento-2.3.3.js +8 -2
- package/lib/config/versions/magento-2.3.4-p1.js +44 -0
- package/lib/config/versions/magento-2.3.4-p2.js +8 -2
- package/lib/config/versions/magento-2.3.4.js +8 -2
- package/lib/config/versions/magento-2.3.5-p1.js +8 -2
- package/lib/config/versions/magento-2.3.5-p2.js +8 -2
- package/lib/config/versions/magento-2.3.5.js +8 -2
- package/lib/config/versions/magento-2.3.6-p1.js +8 -2
- package/lib/config/versions/magento-2.3.6.js +8 -2
- package/lib/config/versions/magento-2.3.7-p1.js +8 -2
- package/lib/config/versions/magento-2.3.7-p2.js +8 -2
- package/lib/config/versions/magento-2.3.7-p3.js +8 -2
- package/lib/config/versions/magento-2.3.7.js +8 -2
- package/lib/config/versions/magento-2.4.0-p1.js +9 -3
- package/lib/config/versions/magento-2.4.0.js +9 -3
- package/lib/config/versions/magento-2.4.1-p1.js +6 -5
- package/lib/config/versions/magento-2.4.1.js +9 -2
- package/lib/config/versions/magento-2.4.2-p1.js +6 -5
- package/lib/config/versions/magento-2.4.2-p2.js +6 -6
- package/lib/config/versions/magento-2.4.2.js +6 -6
- package/lib/config/versions/magento-2.4.3-p1.js +7 -7
- package/lib/config/versions/magento-2.4.3-p2.js +7 -7
- package/lib/config/versions/magento-2.4.3.js +7 -7
- package/lib/config/versions/magento-2.4.4.js +9 -2
- package/lib/tasks/cleanup.js +2 -2
- package/lib/tasks/composer/index.js +14 -104
- package/lib/tasks/docker/api.d.ts +71 -0
- package/lib/tasks/docker/api.js +30 -0
- package/lib/tasks/docker/containers/container-api.d.ts +128 -0
- package/lib/tasks/docker/containers/container-api.js +153 -0
- package/lib/tasks/docker/containers/index.js +19 -0
- package/lib/tasks/docker/containers/tasks.js +215 -0
- package/lib/tasks/docker/convert-legacy-volumes.js +7 -3
- package/lib/tasks/docker/image/image-api.d.ts +34 -0
- package/lib/tasks/docker/image/image-api.js +49 -0
- package/lib/tasks/docker/image/index.js +5 -0
- package/lib/tasks/docker/index.js +1 -13
- package/lib/tasks/docker/network/index.js +7 -0
- package/lib/tasks/docker/network/network-api.d.ts +103 -0
- package/lib/tasks/docker/network/network-api.js +99 -0
- package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
- package/lib/tasks/docker/project-image-builder.js +167 -0
- package/lib/tasks/docker/volumes.js +1 -1
- package/lib/tasks/file-system/create-nginx-config.js +2 -3
- package/lib/tasks/file-system/create-php-config.js +20 -5
- package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
- package/lib/tasks/file-system/create-vscode-config.js +57 -42
- package/lib/tasks/file-system/index.js +2 -1
- package/lib/tasks/link.js +1 -2
- package/lib/tasks/magento/install-magento-project.js +31 -63
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +6 -2
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
- package/lib/tasks/magento/setup-magento/install-magento.js +10 -9
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -8
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/varnish-config.js +6 -4
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
- package/lib/tasks/mysql/connect-to-mysql.js +34 -21
- package/lib/tasks/mysql/import-dump-to-mysql.js +46 -3
- package/lib/tasks/php/php-container.js +108 -0
- package/lib/tasks/php/update-env-php.js +35 -19
- package/lib/tasks/php/update-env.php +61 -56
- package/lib/tasks/php/working_health_check.php +85 -0
- package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
- package/lib/tasks/requirements/docker/index.js +15 -12
- package/lib/tasks/requirements/docker/performance.js +54 -0
- package/lib/tasks/requirements/docker/version.js +8 -8
- package/lib/tasks/requirements/index.js +5 -8
- package/lib/tasks/requirements/php-version.js +8 -116
- package/lib/tasks/requirements/platform.js +12 -25
- package/lib/tasks/start.js +38 -47
- package/lib/tasks/status/index.js +4 -10
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-php-json.js +13 -4
- package/lib/util/dockerfile-builder/build-instructions.js +197 -0
- package/lib/util/dockerfile-builder/index.js +276 -0
- package/lib/util/dockerfile-builder/types.d.ts +123 -0
- package/lib/util/env-php-json.js +10 -6
- package/lib/util/exec-async-command.js +3 -9
- package/lib/util/macos-version.js +20 -0
- package/lib/util/magento-task.js +3 -4
- package/lib/util/nginx-logs-parser.js +122 -0
- package/lib/util/php-task.js +3 -6
- package/lib/util/prefix.js +1 -1
- package/lib/util/run-composer.js +6 -14
- package/lib/util/run-container-image.js +17 -0
- package/lib/util/run-magento.js +6 -14
- package/lib/util/run-php.js +6 -17
- package/package.json +9 -9
- package/typings/context.d.ts +3 -9
- package/typings/index.d.ts +38 -57
- package/lib/config/composer.js +0 -11
- package/lib/config/php/extensions/libsodium.js +0 -36
- package/lib/config/php/releases/php-7.2.js +0 -25
- package/lib/config/php/releases/php-7.3.js +0 -25
- package/lib/config/php/releases/php-7.4.js +0 -23
- package/lib/config/php/releases/php-8.1.js +0 -25
- package/lib/config/phpbrew.js +0 -12
- package/lib/tasks/composer/install-prestissimo.js +0 -103
- package/lib/tasks/docker/containers.js +0 -231
- package/lib/tasks/php/bundled-extensions.js +0 -27
- package/lib/tasks/php/compile-options.js +0 -56
- package/lib/tasks/php/compile.js +0 -55
- package/lib/tasks/php/configure.js +0 -89
- package/lib/tasks/php/extensions/disable.js +0 -49
- package/lib/tasks/php/extensions/enable.js +0 -52
- package/lib/tasks/php/extensions/index.js +0 -80
- package/lib/tasks/php/extensions/install.js +0 -54
- package/lib/tasks/php/index.js +0 -79
- package/lib/tasks/php/install-sodium.js +0 -93
- package/lib/tasks/php/update-phpbrew.js +0 -45
- package/lib/tasks/php/validate-php.js +0 -67
- package/lib/tasks/php-fpm/get-process-id.js +0 -14
- package/lib/tasks/php-fpm/index.js +0 -4
- package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
- package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
- package/lib/tasks/requirements/phpbrew/index.js +0 -61
- package/lib/tasks/requirements/phpbrew/install.js +0 -159
- package/lib/tasks/requirements/phpbrew/version.js +0 -28
package/lib/tasks/stop.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const { stopServices } = require('./docker');
|
|
2
2
|
const getMagentoVersionConfig = require('../config/get-magento-version-config');
|
|
3
|
-
const { stopPhpFpm } = require('./php-fpm');
|
|
4
3
|
const getProjectConfiguration = require('../config/get-project-configuration');
|
|
5
4
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
6
5
|
|
|
@@ -13,7 +12,6 @@ const stop = () => ({
|
|
|
13
12
|
getMagentoVersionConfig(),
|
|
14
13
|
checkConfigurationFile(),
|
|
15
14
|
getProjectConfiguration(),
|
|
16
|
-
stopPhpFpm(),
|
|
17
15
|
stopServices()
|
|
18
16
|
], {
|
|
19
17
|
concurrent: false,
|
|
@@ -18,7 +18,7 @@ const installTheme = (theme) => ({
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
try {
|
|
21
|
-
await runComposerCommand(`require ${theme.composerData.name}`, {
|
|
21
|
+
await runComposerCommand(ctx, `require ${theme.composerData.name}`, {
|
|
22
22
|
magentoVersion,
|
|
23
23
|
callback: !verbose ? undefined : (t) => {
|
|
24
24
|
task.output = t;
|
|
@@ -9,7 +9,7 @@ const runComposerCommand = require('../../util/run-composer');
|
|
|
9
9
|
const symlinkTheme = (theme) => ({
|
|
10
10
|
title: 'Setting symbolic link for theme in composer.json',
|
|
11
11
|
task: async (ctx, task) => {
|
|
12
|
-
const {
|
|
12
|
+
const { verbose = false } = ctx;
|
|
13
13
|
const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
|
|
14
14
|
|
|
15
15
|
if (!composerJsonData.repositories) {
|
|
@@ -27,8 +27,7 @@ const symlinkTheme = (theme) => ({
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
try {
|
|
30
|
-
await runComposerCommand(`config repo.scandipwa path ${theme.absoluteThemePath}`, {
|
|
31
|
-
magentoVersion,
|
|
30
|
+
await runComposerCommand(ctx, `config repo.scandipwa path ${theme.absoluteThemePath}`, {
|
|
32
31
|
callback: !verbose ? undefined : (t) => {
|
|
33
32
|
task.output = t;
|
|
34
33
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const UnknownError = require('../errors/unknown-error');
|
|
3
|
-
const
|
|
3
|
+
const { runPHPContainerCommand } = require('../tasks/php/php-container');
|
|
4
|
+
const pathExists = require('./path-exists');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('../../typings/context').ListrContext} ctx
|
|
8
|
+
*/
|
|
9
|
+
const configPhpToJson = async (ctx) => {
|
|
10
|
+
const configPhpOnSystemPath = path.join(ctx.config.baseConfig.magentoDir, 'app', 'etc', 'config.php');
|
|
11
|
+
const configPhpInContainerPath = path.join(ctx.config.baseConfig.containerMagentoDir, 'app', 'etc', 'config.php');
|
|
12
|
+
if (!await pathExists(configPhpOnSystemPath)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const { code, result } = await runPHPContainerCommand(ctx, `php -r "echo json_encode(require '${configPhpInContainerPath}');"`, {
|
|
16
|
+
withCode: true
|
|
8
17
|
});
|
|
9
18
|
|
|
10
19
|
if (code !== 0) {
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {import('./types').DockerfileInstruction[]} instructions
|
|
4
|
+
*/
|
|
5
|
+
const buildInstructions = (instructions) => {
|
|
6
|
+
/**
|
|
7
|
+
* @type {string[]}
|
|
8
|
+
*/
|
|
9
|
+
const dockerFileInstructions = [];
|
|
10
|
+
|
|
11
|
+
for (const instruction of instructions) {
|
|
12
|
+
switch (instruction.type) {
|
|
13
|
+
case 'COPY':
|
|
14
|
+
case 'ADD': {
|
|
15
|
+
let addInstruction = instruction.type;
|
|
16
|
+
|
|
17
|
+
if (instruction.type === 'COPY' && instruction.from) {
|
|
18
|
+
addInstruction += ` --from=${instruction.from}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (instruction.chown) {
|
|
22
|
+
addInstruction += ` --chown=${instruction.chown}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
addInstruction += ` ${instruction.src.join(' ')}`;
|
|
26
|
+
addInstruction += ` ${instruction.dest}`;
|
|
27
|
+
|
|
28
|
+
dockerFileInstructions.push(addInstruction);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
case 'ARG': {
|
|
32
|
+
let argInstruction = instruction.type;
|
|
33
|
+
|
|
34
|
+
argInstruction += ` ${instruction.name}`;
|
|
35
|
+
|
|
36
|
+
if (instruction.defaultValue) {
|
|
37
|
+
argInstruction += `=${instruction.defaultValue}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
dockerFileInstructions.push(argInstruction);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'RUN':
|
|
44
|
+
case 'ENTRYPOINT':
|
|
45
|
+
case 'CMD': {
|
|
46
|
+
let cmdInstruction = instruction.type;
|
|
47
|
+
|
|
48
|
+
if (typeof instruction.command === 'string') {
|
|
49
|
+
cmdInstruction += ` ${instruction.command}`;
|
|
50
|
+
} else if (Array.isArray(instruction.command) && instruction.command.every((c) => typeof c === 'string')) {
|
|
51
|
+
cmdInstruction += ` ["${instruction.command.join('", "')}"]`;
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error(`Unknown command type, it must be string or array of strings! ${instruction.command}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
dockerFileInstructions.push(cmdInstruction);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
case 'COMMENT': {
|
|
61
|
+
const commentInstruction = `# ${instruction.comment}`;
|
|
62
|
+
|
|
63
|
+
dockerFileInstructions.push(commentInstruction);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case 'ENV': {
|
|
67
|
+
let envInstruction = instruction.type;
|
|
68
|
+
|
|
69
|
+
envInstruction += ` ${instruction.name}="${instruction.value}"`;
|
|
70
|
+
|
|
71
|
+
dockerFileInstructions.push(envInstruction);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case 'EXPOSE': {
|
|
75
|
+
let exposeInstruction = instruction.type;
|
|
76
|
+
|
|
77
|
+
if (instruction.protocol) {
|
|
78
|
+
exposeInstruction += ` ${instruction.port}/${instruction.protocol}`;
|
|
79
|
+
} else {
|
|
80
|
+
exposeInstruction += ` ${instruction.port}`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dockerFileInstructions.push(exposeInstruction);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'FROM': {
|
|
87
|
+
let fromInstruction = instruction.type;
|
|
88
|
+
|
|
89
|
+
if (instruction.platform) {
|
|
90
|
+
fromInstruction += ` --platform=${instruction.platform}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fromInstruction += ` ${instruction.image}:${instruction.tag || 'latest'}`;
|
|
94
|
+
|
|
95
|
+
if (instruction.name) {
|
|
96
|
+
fromInstruction += ` AS ${instruction.name}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
dockerFileInstructions.push(fromInstruction);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case 'HEALTHCHECK': {
|
|
103
|
+
let healthCheckInstruction = instruction.type;
|
|
104
|
+
|
|
105
|
+
if (instruction.interval) {
|
|
106
|
+
healthCheckInstruction += ` --interval=${instruction.interval}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (instruction.retries) {
|
|
110
|
+
healthCheckInstruction += ` --retries=${instruction.retries}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (instruction.startPeriod) {
|
|
114
|
+
healthCheckInstruction += ` --start-period=${instruction.startPeriod}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (instruction.timeout) {
|
|
118
|
+
healthCheckInstruction += ` --timeout=${instruction.timeout}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
healthCheckInstruction += ` ${instruction.command}`;
|
|
122
|
+
|
|
123
|
+
dockerFileInstructions.push(healthCheckInstruction);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 'LABEL': {
|
|
127
|
+
Object.entries(instruction.labels).forEach(([name, value]) => {
|
|
128
|
+
let labelInstruction = instruction.type;
|
|
129
|
+
labelInstruction += ` "${name}"="${value}"`;
|
|
130
|
+
dockerFileInstructions.push(labelInstruction);
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
case 'ONBUILD': {
|
|
135
|
+
let onBuildInstruction = instruction.type;
|
|
136
|
+
|
|
137
|
+
onBuildInstruction += ` ${instruction.instruction}`;
|
|
138
|
+
|
|
139
|
+
dockerFileInstructions.push(onBuildInstruction);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case 'SHELL': {
|
|
143
|
+
let shellInstruction = instruction.type;
|
|
144
|
+
|
|
145
|
+
shellInstruction += ` ["${instruction.exec.join('", "')}"]`;
|
|
146
|
+
|
|
147
|
+
dockerFileInstructions.push(shellInstruction);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
case 'STOPSIGNAL': {
|
|
151
|
+
let stopSignalInstruction = instruction.type;
|
|
152
|
+
|
|
153
|
+
stopSignalInstruction += ` ${instruction.signal}`;
|
|
154
|
+
|
|
155
|
+
dockerFileInstructions.push(stopSignalInstruction);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case 'USER': {
|
|
159
|
+
let userInstruction = instruction.type;
|
|
160
|
+
|
|
161
|
+
userInstruction += ` ${instruction.user}`;
|
|
162
|
+
|
|
163
|
+
dockerFileInstructions.push(userInstruction);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case 'VOLUME': {
|
|
167
|
+
let volumeInstruction = instruction.type;
|
|
168
|
+
|
|
169
|
+
if (typeof instruction.volume === 'string') {
|
|
170
|
+
volumeInstruction += ` ${instruction.volume}`;
|
|
171
|
+
} else if (Array.isArray(instruction.volume) && instruction.volume.every((c) => typeof c === 'string')) {
|
|
172
|
+
volumeInstruction += ` ["${instruction.volume.join('", "')}"]`;
|
|
173
|
+
} else {
|
|
174
|
+
throw new Error(`Unknown volume type, it must be string or array of strings! ${instruction.volume}`);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
dockerFileInstructions.push(volumeInstruction);
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
case 'WORKDIR': {
|
|
181
|
+
const workDirInstruction = `${instruction.type} ${instruction.workdir}`;
|
|
182
|
+
|
|
183
|
+
dockerFileInstructions.push(workDirInstruction);
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
default: {
|
|
187
|
+
throw new Error(`I don't know instruction with type ${instruction.type}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return dockerFileInstructions.join('\n');
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
module.exports = {
|
|
196
|
+
buildInstructions
|
|
197
|
+
};
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
const { buildInstructions } = require('./build-instructions');
|
|
2
|
+
|
|
3
|
+
class DockerFileBuilder {
|
|
4
|
+
/**
|
|
5
|
+
* @type {import('./types').DockerfileInstruction[]}
|
|
6
|
+
*/
|
|
7
|
+
instructions = [];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @param {Omit<import('./types').FromInstruction, 'type'>} param0
|
|
11
|
+
* @returns {this}
|
|
12
|
+
*/
|
|
13
|
+
from({
|
|
14
|
+
image,
|
|
15
|
+
tag = 'latest',
|
|
16
|
+
platform,
|
|
17
|
+
name
|
|
18
|
+
}) {
|
|
19
|
+
this.instructions.push({
|
|
20
|
+
type: 'FROM',
|
|
21
|
+
image,
|
|
22
|
+
tag,
|
|
23
|
+
platform,
|
|
24
|
+
name
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {import('./types').RunInstruction['command']} command
|
|
32
|
+
*/
|
|
33
|
+
run(command) {
|
|
34
|
+
this.instructions.push({
|
|
35
|
+
type: 'RUN',
|
|
36
|
+
command
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @param {import('./types').CmdInstruction['command']} command
|
|
44
|
+
*/
|
|
45
|
+
cmd(command) {
|
|
46
|
+
this.instructions.push({
|
|
47
|
+
type: 'CMD',
|
|
48
|
+
command
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param {import('./types').LabelInstruction['labels']} labels
|
|
56
|
+
*/
|
|
57
|
+
label(labels) {
|
|
58
|
+
this.instructions.push({
|
|
59
|
+
type: 'LABEL',
|
|
60
|
+
labels
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {Omit<import('./types').ExposeInstruction, 'type'>} param0
|
|
68
|
+
*/
|
|
69
|
+
expose({
|
|
70
|
+
port,
|
|
71
|
+
protocol
|
|
72
|
+
}) {
|
|
73
|
+
this.instructions.push({
|
|
74
|
+
type: 'EXPOSE',
|
|
75
|
+
port,
|
|
76
|
+
protocol
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {Record<string, string>} env
|
|
84
|
+
*/
|
|
85
|
+
env(env) {
|
|
86
|
+
Object.entries(env).forEach(([name, value]) => {
|
|
87
|
+
this.instructions.push({
|
|
88
|
+
type: 'ENV',
|
|
89
|
+
name,
|
|
90
|
+
value
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {Omit<import('./types').AddInstruction, 'type'>} param0
|
|
99
|
+
*/
|
|
100
|
+
add({
|
|
101
|
+
src,
|
|
102
|
+
dest,
|
|
103
|
+
chown
|
|
104
|
+
}) {
|
|
105
|
+
this.instructions.push({
|
|
106
|
+
type: 'ADD',
|
|
107
|
+
src,
|
|
108
|
+
dest,
|
|
109
|
+
chown
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @param {Omit<import('./types').CopyInstruction, 'type'>} param0
|
|
117
|
+
*/
|
|
118
|
+
copy({
|
|
119
|
+
src,
|
|
120
|
+
dest,
|
|
121
|
+
chown,
|
|
122
|
+
from
|
|
123
|
+
}) {
|
|
124
|
+
this.instructions.push({
|
|
125
|
+
type: 'COPY',
|
|
126
|
+
src,
|
|
127
|
+
dest,
|
|
128
|
+
chown,
|
|
129
|
+
from
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return this;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @param {import('./types').EntrypointInstruction['command']} command
|
|
137
|
+
*/
|
|
138
|
+
entrypoint(command) {
|
|
139
|
+
this.instructions.push({
|
|
140
|
+
type: 'ENTRYPOINT',
|
|
141
|
+
command
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @param {import('./types').VolumeInstruction['volume']} volume
|
|
149
|
+
*/
|
|
150
|
+
volume(volume) {
|
|
151
|
+
this.instructions.push({
|
|
152
|
+
type: 'VOLUME',
|
|
153
|
+
volume
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @param {import('./types').UserInstruction['user']} user
|
|
161
|
+
*/
|
|
162
|
+
user(user) {
|
|
163
|
+
this.instructions.push({
|
|
164
|
+
type: 'USER',
|
|
165
|
+
user
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {import('./types').WorkDirInstruction['workdir']} workdir
|
|
173
|
+
*/
|
|
174
|
+
workDir(workdir) {
|
|
175
|
+
this.instructions.push({
|
|
176
|
+
type: 'WORKDIR',
|
|
177
|
+
workdir
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @param {Omit<import('./types').ArgInstruction, 'type'>} param0
|
|
185
|
+
*/
|
|
186
|
+
arg({
|
|
187
|
+
name,
|
|
188
|
+
defaultValue
|
|
189
|
+
}) {
|
|
190
|
+
this.instructions.push({
|
|
191
|
+
type: 'ARG',
|
|
192
|
+
name,
|
|
193
|
+
defaultValue
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {import('./types').OnBuildInstruction['instruction']} instruction
|
|
201
|
+
*/
|
|
202
|
+
onBuild(instruction) {
|
|
203
|
+
this.instructions.push({
|
|
204
|
+
type: 'ONBUILD',
|
|
205
|
+
instruction
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
return this;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* @param {import('./types').StopSignalInstruction['signal']} signal
|
|
213
|
+
*/
|
|
214
|
+
stopSignal(signal) {
|
|
215
|
+
this.instructions.push({
|
|
216
|
+
type: 'STOPSIGNAL',
|
|
217
|
+
signal
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* @param {Omit<import('./types').HealthCheckInstruction, 'type'>} param0
|
|
225
|
+
*/
|
|
226
|
+
healthCheck({
|
|
227
|
+
command,
|
|
228
|
+
interval,
|
|
229
|
+
timeout,
|
|
230
|
+
startPeriod,
|
|
231
|
+
retries
|
|
232
|
+
}) {
|
|
233
|
+
this.instructions.push({
|
|
234
|
+
type: 'HEALTHCHECK',
|
|
235
|
+
command,
|
|
236
|
+
interval,
|
|
237
|
+
retries,
|
|
238
|
+
startPeriod,
|
|
239
|
+
timeout
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
return this;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* @param {import('./types').ShellInstruction['exec']} exec
|
|
247
|
+
*/
|
|
248
|
+
shell(exec) {
|
|
249
|
+
this.instructions.push({
|
|
250
|
+
type: 'SHELL',
|
|
251
|
+
exec
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
return this;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @param {import('./types').CommentInstruction['comment']} comment
|
|
259
|
+
*/
|
|
260
|
+
comment(comment) {
|
|
261
|
+
this.instructions.push({
|
|
262
|
+
type: 'COMMENT',
|
|
263
|
+
comment
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
build() {
|
|
270
|
+
return buildInstructions(this.instructions);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
module.exports = {
|
|
275
|
+
DockerFileBuilder
|
|
276
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
export interface FromInstruction {
|
|
2
|
+
type: 'FROM'
|
|
3
|
+
image: string
|
|
4
|
+
tag?: string
|
|
5
|
+
platform?: string
|
|
6
|
+
name?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface RunInstruction {
|
|
10
|
+
type: 'RUN'
|
|
11
|
+
command: string | string[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CmdInstruction {
|
|
15
|
+
type: 'CMD'
|
|
16
|
+
command: string | string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LabelInstruction {
|
|
20
|
+
type: 'LABEL'
|
|
21
|
+
labels: Record<string, string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ExposeInstruction {
|
|
25
|
+
type: 'EXPOSE'
|
|
26
|
+
port: number
|
|
27
|
+
protocol?: 'udp' | 'tcp'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface EnvInstruction {
|
|
31
|
+
type: 'ENV'
|
|
32
|
+
name: string
|
|
33
|
+
value: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface AddInstruction {
|
|
37
|
+
type: 'ADD'
|
|
38
|
+
src: string[]
|
|
39
|
+
dest: string
|
|
40
|
+
chown?: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface CopyInstruction {
|
|
44
|
+
type: 'COPY'
|
|
45
|
+
src: string[]
|
|
46
|
+
dest: string
|
|
47
|
+
chown?: string
|
|
48
|
+
from?: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface EntrypointInstruction {
|
|
52
|
+
type: 'ENTRYPOINT'
|
|
53
|
+
command: string | string[]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface VolumeInstruction {
|
|
57
|
+
type: 'VOLUME'
|
|
58
|
+
volume: string | string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface UserInstruction {
|
|
62
|
+
type: 'USER'
|
|
63
|
+
user: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface WorkDirInstruction {
|
|
67
|
+
type: 'WORKDIR'
|
|
68
|
+
workdir: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ArgInstruction {
|
|
72
|
+
type: 'ARG'
|
|
73
|
+
name: string
|
|
74
|
+
defaultValue?: string
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface OnBuildInstruction {
|
|
78
|
+
type: 'ONBUILD'
|
|
79
|
+
instruction: string
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface StopSignalInstruction {
|
|
83
|
+
type: 'STOPSIGNAL'
|
|
84
|
+
signal: string
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface HealthCheckInstruction {
|
|
88
|
+
type: 'HEALTHCHECK'
|
|
89
|
+
command: string
|
|
90
|
+
interval?: string
|
|
91
|
+
timeout?: string
|
|
92
|
+
startPeriod?: string
|
|
93
|
+
retries?: number
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ShellInstruction {
|
|
97
|
+
type: 'SHELL'
|
|
98
|
+
exec: string[]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface CommentInstruction {
|
|
102
|
+
type: 'COMMENT'
|
|
103
|
+
comment: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type DockerfileInstruction = FromInstruction
|
|
107
|
+
| RunInstruction
|
|
108
|
+
| CmdInstruction
|
|
109
|
+
| LabelInstruction
|
|
110
|
+
| ExposeInstruction
|
|
111
|
+
| EnvInstruction
|
|
112
|
+
| AddInstruction
|
|
113
|
+
| CopyInstruction
|
|
114
|
+
| EntrypointInstruction
|
|
115
|
+
| VolumeInstruction
|
|
116
|
+
| UserInstruction
|
|
117
|
+
| WorkDirInstruction
|
|
118
|
+
| ArgInstruction
|
|
119
|
+
| OnBuildInstruction
|
|
120
|
+
| StopSignalInstruction
|
|
121
|
+
| HealthCheckInstruction
|
|
122
|
+
| ShellInstruction
|
|
123
|
+
| CommentInstruction
|
package/lib/util/env-php-json.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const UnknownError = require('../errors/unknown-error');
|
|
3
|
+
const { runPHPContainerCommand } = require('../tasks/php/php-container');
|
|
3
4
|
const pathExists = require('./path-exists');
|
|
4
|
-
const runPhpCode = require('./run-php');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @param {import('../../typings/context').ListrContext} ctx
|
|
8
|
+
*/
|
|
9
|
+
const envPhpToJson = async (ctx) => {
|
|
10
|
+
const envPhpOnSystemPath = path.join(ctx.config.baseConfig.magentoDir, 'app', 'etc', 'env.php');
|
|
11
|
+
const envPhpInContainerPath = path.join(ctx.config.baseConfig.containerMagentoDir, 'app', 'etc', 'env.php');
|
|
12
|
+
if (!await pathExists(envPhpOnSystemPath)) {
|
|
9
13
|
return null;
|
|
10
14
|
}
|
|
11
|
-
const { code, result } = await
|
|
12
|
-
|
|
15
|
+
const { code, result } = await runPHPContainerCommand(ctx, `php -r "echo json_encode(require '${envPhpInContainerPath}');"`, {
|
|
16
|
+
withCode: true
|
|
13
17
|
});
|
|
14
18
|
|
|
15
19
|
if (code !== 0) {
|