@scandipwa/magento-scripts 2.0.0-alpha.10 → 2.0.0-alpha.11
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 +5 -0
- package/lib/commands/start.js +17 -3
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +43 -44
- package/lib/config/index.js +1 -1
- package/lib/config/php/versions/php-7.2.js +1 -0
- package/lib/config/php/versions/php-7.3.js +1 -0
- package/lib/config/php/versions/php-7.4.js +1 -0
- package/lib/config/php/versions/php-8.1.js +1 -0
- package/lib/config/php-config.js +4 -3
- package/lib/config/services/composer/versions/composer-1.js +8 -0
- package/lib/config/services/composer/versions/composer-2.js +8 -0
- package/lib/config/services/composer/versions/index.js +4 -0
- package/lib/config/services/nginx/versions/index.js +3 -0
- package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
- package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
- package/lib/config/templates/magentorc.template +6 -5
- package/lib/config/templates/php-debug.template.ini +31 -0
- package/lib/config/templates/php-fpm.template.conf +1 -2
- package/lib/config/templates/php.template.ini +6 -202
- package/lib/config/templates/ssl-terminator.template.conf +2 -0
- package/lib/config/templates/varnish.template.vcl +20 -13
- package/lib/config/varnish/varnish-6-0.js +4 -0
- package/lib/config/varnish/varnish-6-6.js +4 -0
- package/lib/config/varnish/varnish-7-0.js +4 -0
- package/lib/config/versions/magento-2.3.0.js +5 -9
- package/lib/config/versions/magento-2.3.1.js +5 -9
- package/lib/config/versions/magento-2.3.2-p1.js +5 -9
- package/lib/config/versions/magento-2.3.2-p2.js +5 -9
- package/lib/config/versions/magento-2.3.2.js +5 -9
- package/lib/config/versions/magento-2.3.3-p1.js +5 -9
- package/lib/config/versions/magento-2.3.3.js +5 -9
- package/lib/config/versions/magento-2.3.4-p1.js +5 -9
- package/lib/config/versions/magento-2.3.4-p2.js +5 -9
- package/lib/config/versions/magento-2.3.4.js +5 -9
- package/lib/config/versions/magento-2.3.5-p1.js +5 -9
- package/lib/config/versions/magento-2.3.5-p2.js +5 -9
- package/lib/config/versions/magento-2.3.5.js +5 -9
- package/lib/config/versions/magento-2.3.6-p1.js +5 -9
- package/lib/config/versions/magento-2.3.6.js +5 -9
- package/lib/config/versions/magento-2.3.7-p1.js +5 -9
- package/lib/config/versions/magento-2.3.7-p2.js +5 -9
- package/lib/config/versions/magento-2.3.7-p3.js +5 -9
- package/lib/config/versions/magento-2.3.7-p4.js +5 -9
- package/lib/config/versions/magento-2.3.7.js +5 -9
- package/lib/config/versions/magento-2.4.0-p1.js +5 -9
- package/lib/config/versions/magento-2.4.0.js +5 -9
- package/lib/config/versions/magento-2.4.1-p1.js +5 -9
- package/lib/config/versions/magento-2.4.1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p1.js +5 -9
- package/lib/config/versions/magento-2.4.2-p2.js +5 -9
- package/lib/config/versions/magento-2.4.2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p1.js +5 -9
- package/lib/config/versions/magento-2.4.3-p2.js +5 -9
- package/lib/config/versions/magento-2.4.3-p3.js +5 -9
- package/lib/config/versions/magento-2.4.3.js +5 -9
- package/lib/config/versions/magento-2.4.4-p1.js +5 -9
- package/lib/config/versions/magento-2.4.4.js +5 -9
- package/lib/config/versions/magento-2.4.5.js +5 -9
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +6 -3
- package/lib/tasks/database/create-magento-database.js +5 -2
- package/lib/tasks/database/create-magento-user.js +50 -0
- package/lib/tasks/database/default-magento-database.js +3 -0
- package/lib/tasks/database/default-magento-user.js +7 -0
- package/lib/tasks/database/import-dump-to-database.js +3 -2
- package/lib/tasks/docker/api.d.ts +25 -1
- package/lib/tasks/docker/api.js +31 -1
- package/lib/tasks/docker/containers/container-api.d.ts +14 -0
- package/lib/tasks/docker/containers/container-api.js +50 -1
- package/lib/tasks/docker/containers/tasks.js +32 -1
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/project-image-builder.js +6 -8
- package/lib/tasks/docker/volume/index.js +2 -1
- package/lib/tasks/docker/volume/tasks.js +54 -9
- package/lib/tasks/docker/volume/volume-api.d.ts +10 -0
- package/lib/tasks/docker/volume/volume-api.js +25 -1
- package/lib/tasks/execute.js +5 -2
- package/lib/tasks/file-system/create-nginx-config.js +3 -5
- package/lib/tasks/file-system/create-php-config.js +2 -23
- package/lib/tasks/file-system/create-php-debug-config.js +45 -0
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/index.js +2 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
- package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
- package/lib/tasks/php/php-container.js +1 -1
- package/lib/tasks/php/update-env-php.js +3 -4
- package/lib/tasks/requirements/composer-credentials.js +7 -3
- package/lib/tasks/requirements/docker/context.js +88 -0
- package/lib/tasks/requirements/docker/index.js +107 -18
- package/lib/tasks/requirements/docker/install.js +21 -7
- package/lib/tasks/requirements/docker/permissions.js +2 -11
- package/lib/tasks/requirements/docker/running-status.js +94 -24
- package/lib/tasks/requirements/docker/version.js +1 -0
- package/lib/tasks/requirements/index.js +0 -2
- package/lib/tasks/requirements/php-version.js +4 -2
- package/lib/tasks/start.js +27 -6
- package/lib/tasks/status/index.js +13 -11
- package/lib/tasks/stop.js +2 -0
- package/lib/util/config-file-validator.js +2 -0
- package/lib/util/execute-in-container.js +3 -3
- package/lib/util/systemctl.js +62 -13
- package/package.json +2 -2
- package/typings/context.d.ts +7 -0
- package/typings/index.d.ts +38 -1
- package/lib/tasks/requirements/dependency/arch.js +0 -50
- package/lib/tasks/requirements/dependency/centos.js +0 -36
- package/lib/tasks/requirements/dependency/fedora.js +0 -36
- package/lib/tasks/requirements/dependency/index.js +0 -33
- package/lib/tasks/requirements/dependency/mac.js +0 -124
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
|
@@ -27,13 +27,13 @@ const getEnabledExtensionsFromImage = async (imageWithTag) => {
|
|
|
27
27
|
.reduce((acc, [name, version]) => ({ ...acc, [name]: version }), {});
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
const addExtensionToBuilder = (builder, ctx) => ([extensionName, extensionInstructions]) => {
|
|
30
|
+
const addExtensionToBuilder = (builder, ctx) => async ([extensionName, extensionInstructions]) => {
|
|
31
31
|
const { command, ...extensionInstructionsWithoutCommand } = extensionInstructions;
|
|
32
32
|
let runCommand = '';
|
|
33
33
|
if (typeof command === 'string') {
|
|
34
34
|
runCommand += ` ${command}`;
|
|
35
|
-
} else if (typeof command === 'function') {
|
|
36
|
-
runCommand += ` ${command({ ...extensionInstructionsWithoutCommand, ctx })}`;
|
|
35
|
+
} else if (typeof command === 'function' || command instanceof Promise) {
|
|
36
|
+
runCommand += ` ${await Promise.resolve(command({ ...extensionInstructionsWithoutCommand, ctx }))}`;
|
|
37
37
|
} else {
|
|
38
38
|
runCommand += ` docker-php-ext-install ${extensionInstructionsWithoutCommand.name}`;
|
|
39
39
|
}
|
|
@@ -68,10 +68,6 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
|
68
68
|
.comment('project image')
|
|
69
69
|
.from({ image, tag });
|
|
70
70
|
|
|
71
|
-
// install bash and patch in image
|
|
72
|
-
dockerFileInstructions
|
|
73
|
-
.run('apk add --no-cache bash patch');
|
|
74
|
-
|
|
75
71
|
if (missingExtensions.length > 0) {
|
|
76
72
|
const allDependencies = missingExtensions.map(
|
|
77
73
|
([_extensionName, extensionInstructions]) => (extensionInstructions.dependencies || [])
|
|
@@ -79,7 +75,9 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
|
79
75
|
.reduce((acc, val) => acc.concat(val.filter((ex) => !acc.includes(ex))), []);
|
|
80
76
|
|
|
81
77
|
dockerFileInstructions.run(`apk add --no-cache ${allDependencies.join(' ')}`);
|
|
82
|
-
|
|
78
|
+
for (const missingExtensionInstructions of missingExtensions) {
|
|
79
|
+
await addExtensionToBuilder(dockerFileInstructions, ctx)(missingExtensionInstructions);
|
|
80
|
+
}
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
const composerVersion = /^\d$/.test(composer.version)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const volumeApi = require('./volume-api');
|
|
2
|
-
const { createVolumes, removeVolumes } = require('./tasks');
|
|
2
|
+
const { createVolumes, removeVolumes, removeLocalVolumes } = require('./tasks');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
createVolumes,
|
|
6
6
|
removeVolumes,
|
|
7
|
+
removeLocalVolumes,
|
|
7
8
|
volumeApi
|
|
8
9
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const pathExists = require('../../../util/path-exists');
|
|
3
|
+
const volumeApi = require('./volume-api');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -7,10 +8,12 @@ const { create } = require('./volume-api');
|
|
|
7
8
|
const createVolumes = () => ({
|
|
8
9
|
title: 'Creating volumes',
|
|
9
10
|
task: async ({ config: { docker } }, task) => {
|
|
10
|
-
const volumeList =
|
|
11
|
+
const volumeList = await volumeApi.ls({
|
|
12
|
+
formatToJSON: true
|
|
13
|
+
});
|
|
11
14
|
|
|
12
15
|
const missingVolumes = Object.values(docker.volumes).filter(
|
|
13
|
-
({ name }) => !volumeList.
|
|
16
|
+
({ name }) => !volumeList.some((v) => v.Name === name)
|
|
14
17
|
);
|
|
15
18
|
|
|
16
19
|
if (missingVolumes.length === 0) {
|
|
@@ -18,7 +21,15 @@ const createVolumes = () => ({
|
|
|
18
21
|
return;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
await Promise.all(missingVolumes.map((volume) =>
|
|
24
|
+
await Promise.all(missingVolumes.map(async (volume) => {
|
|
25
|
+
if (volume.opt && volume.opt.device && !await pathExists(volume.opt.device)) {
|
|
26
|
+
await fs.promises.mkdir(volume.opt.device, {
|
|
27
|
+
recursive: true
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
await Promise.all(missingVolumes.map((volume) => volumeApi.create(volume)));
|
|
22
33
|
}
|
|
23
34
|
});
|
|
24
35
|
|
|
@@ -28,10 +39,12 @@ const createVolumes = () => ({
|
|
|
28
39
|
const removeVolumes = () => ({
|
|
29
40
|
title: 'Removing volumes',
|
|
30
41
|
task: async ({ config: { docker } }, task) => {
|
|
31
|
-
const volumeList =
|
|
42
|
+
const volumeList = await volumeApi.ls({
|
|
43
|
+
formatToJSON: true
|
|
44
|
+
});
|
|
32
45
|
|
|
33
46
|
const deployedVolumes = Object.values(docker.volumes).filter(
|
|
34
|
-
({ name }) => volumeList.
|
|
47
|
+
({ name }) => volumeList.some((v) => v.Name === name)
|
|
35
48
|
);
|
|
36
49
|
|
|
37
50
|
if (deployedVolumes.length === 0) {
|
|
@@ -39,11 +52,43 @@ const removeVolumes = () => ({
|
|
|
39
52
|
return;
|
|
40
53
|
}
|
|
41
54
|
|
|
42
|
-
await
|
|
55
|
+
await volumeApi.rm({
|
|
56
|
+
volumes: deployedVolumes.map(({ name }) => name)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
63
|
+
*/
|
|
64
|
+
const removeLocalVolumes = () => ({
|
|
65
|
+
title: 'Removing local volumes',
|
|
66
|
+
task: async (ctx, task) => {
|
|
67
|
+
const volumeList = await volumeApi.ls({
|
|
68
|
+
formatToJSON: true
|
|
69
|
+
});
|
|
70
|
+
const { volumes } = ctx.config.docker;
|
|
71
|
+
|
|
72
|
+
const localVolumes = Object.values(volumes).filter(
|
|
73
|
+
(volume) => volume.opt && volume.opt.device
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const existingLocalVolumes = localVolumes.filter(
|
|
77
|
+
(volume) => volumeList.some((v) => v.Name === volume.name)
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (existingLocalVolumes.length > 0) {
|
|
81
|
+
await volumeApi.rm({
|
|
82
|
+
volumes: existingLocalVolumes.map((volume) => volume.name)
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
task.skip();
|
|
86
|
+
}
|
|
43
87
|
}
|
|
44
88
|
});
|
|
45
89
|
|
|
46
90
|
module.exports = {
|
|
47
91
|
createVolumes,
|
|
48
|
-
removeVolumes
|
|
92
|
+
removeVolumes,
|
|
93
|
+
removeLocalVolumes
|
|
49
94
|
};
|
|
@@ -37,3 +37,13 @@ export function create(
|
|
|
37
37
|
options?: VolumeCreateOptions,
|
|
38
38
|
execOptions?: ExecAsyncSpawnOptions<false>
|
|
39
39
|
): Promise<string>
|
|
40
|
+
|
|
41
|
+
export interface VolumeRmOptions {
|
|
42
|
+
force?: boolean
|
|
43
|
+
volumes: string[]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function rm(
|
|
47
|
+
options?: VolumeRmOptions,
|
|
48
|
+
execOptions?: ExecAsyncSpawnOptions<false>
|
|
49
|
+
): Promise<string>
|
|
@@ -60,7 +60,31 @@ const ls = async (options, execOptions = {}) => {
|
|
|
60
60
|
return execAsyncSpawn(`docker volume ls ${args}`, execOptions);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @param {import('./volume-api').VolumeRmOptions} options
|
|
65
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
|
|
66
|
+
*/
|
|
67
|
+
const rm = async (options, execOptions = {}) => {
|
|
68
|
+
const {
|
|
69
|
+
force,
|
|
70
|
+
volumes
|
|
71
|
+
} = options;
|
|
72
|
+
|
|
73
|
+
const forceArg = force && '--force';
|
|
74
|
+
|
|
75
|
+
const command = [
|
|
76
|
+
'docker',
|
|
77
|
+
'volume',
|
|
78
|
+
'rm',
|
|
79
|
+
forceArg,
|
|
80
|
+
...volumes
|
|
81
|
+
].filter(Boolean).join(' ');
|
|
82
|
+
|
|
83
|
+
return execAsyncSpawn(command, execOptions);
|
|
84
|
+
};
|
|
85
|
+
|
|
63
86
|
module.exports = {
|
|
64
87
|
create,
|
|
65
|
-
ls
|
|
88
|
+
ls,
|
|
89
|
+
rm
|
|
66
90
|
};
|
package/lib/tasks/execute.js
CHANGED
|
@@ -7,6 +7,7 @@ const getProjectConfiguration = require('../config/get-project-configuration');
|
|
|
7
7
|
const { getCachedPorts } = require('../config/get-port-config');
|
|
8
8
|
const { executeInContainer, runInContainer } = require('../util/execute-in-container');
|
|
9
9
|
const { containerApi } = require('./docker/containers');
|
|
10
|
+
const dockerNetwork = require('./docker/network');
|
|
10
11
|
const KnownError = require('../errors/known-error');
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -20,7 +21,8 @@ const executeTask = async (argv) => {
|
|
|
20
21
|
getMagentoVersionConfig(),
|
|
21
22
|
checkConfigurationFile(),
|
|
22
23
|
getProjectConfiguration(),
|
|
23
|
-
getCachedPorts()
|
|
24
|
+
getCachedPorts(),
|
|
25
|
+
dockerNetwork.tasks.createNetwork()
|
|
24
26
|
], {
|
|
25
27
|
concurrent: false,
|
|
26
28
|
exitOnError: true,
|
|
@@ -67,7 +69,8 @@ const executeTask = async (argv) => {
|
|
|
67
69
|
logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands.join(' '))})`);
|
|
68
70
|
const result = await executeInContainer({
|
|
69
71
|
containerName: container.name,
|
|
70
|
-
commands: argv.commands
|
|
72
|
+
commands: argv.commands,
|
|
73
|
+
isDockerDesktop: ctx.isDockerDesktop
|
|
71
74
|
});
|
|
72
75
|
|
|
73
76
|
return result;
|
|
@@ -14,7 +14,7 @@ const createNginxConfig = () => ({
|
|
|
14
14
|
overridenConfiguration,
|
|
15
15
|
baseConfig
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
isDockerDesktop
|
|
18
18
|
} = ctx;
|
|
19
19
|
|
|
20
20
|
const {
|
|
@@ -23,10 +23,8 @@ const createNginxConfig = () => ({
|
|
|
23
23
|
}
|
|
24
24
|
} = overridenConfiguration;
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
29
|
-
const hostPort = isNativeLinux ? ports.app : 80;
|
|
26
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
27
|
+
const hostPort = !isDockerDesktop ? ports.app : 80;
|
|
30
28
|
|
|
31
29
|
try {
|
|
32
30
|
await setConfigFile({
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
const semver = require('semver');
|
|
2
1
|
const UnknownError = require('../../errors/unknown-error');
|
|
3
2
|
const setConfigFile = require('../../util/set-config');
|
|
4
|
-
const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -9,32 +7,13 @@ const { getEnabledExtensionsFromImage } = require('../docker/project-image-build
|
|
|
9
7
|
const createPhpConfig = () => ({
|
|
10
8
|
title: 'Setting PHP config',
|
|
11
9
|
task: async (ctx) => {
|
|
12
|
-
const {
|
|
13
|
-
config: {
|
|
14
|
-
php,
|
|
15
|
-
baseConfig
|
|
16
|
-
},
|
|
17
|
-
debug
|
|
18
|
-
} = ctx;
|
|
19
|
-
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
-
const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
|
|
21
|
-
const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
|
|
22
|
-
|
|
23
|
-
const isLinux = ctx.platform === 'linux';
|
|
24
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
25
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
|
+
const { config: { php } } = ctx;
|
|
26
11
|
|
|
27
12
|
try {
|
|
28
13
|
await setConfigFile({
|
|
29
14
|
configPathname: php.iniPath,
|
|
30
15
|
template: php.iniTemplatePath,
|
|
31
|
-
overwrite: true
|
|
32
|
-
templateArgs: {
|
|
33
|
-
debug,
|
|
34
|
-
mageRoot: baseConfig.containerMagentoDir,
|
|
35
|
-
isXDebug2,
|
|
36
|
-
hostMachine
|
|
37
|
-
}
|
|
16
|
+
overwrite: true
|
|
38
17
|
});
|
|
39
18
|
} catch (e) {
|
|
40
19
|
throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const semver = require('semver');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
+
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
8
|
+
*/
|
|
9
|
+
const createPhpDebugConfig = () => ({
|
|
10
|
+
title: 'Setting PHP XDebug config',
|
|
11
|
+
skip: (ctx) => !ctx.debug,
|
|
12
|
+
task: async (ctx) => {
|
|
13
|
+
const {
|
|
14
|
+
config: {
|
|
15
|
+
php,
|
|
16
|
+
baseConfig
|
|
17
|
+
},
|
|
18
|
+
debug,
|
|
19
|
+
isDockerDesktop
|
|
20
|
+
} = ctx;
|
|
21
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
22
|
+
const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
|
|
23
|
+
const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
|
|
24
|
+
|
|
25
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await setConfigFile({
|
|
29
|
+
configPathname: php.debugIniPath,
|
|
30
|
+
template: php.debugTemplatePath,
|
|
31
|
+
overwrite: true,
|
|
32
|
+
templateArgs: {
|
|
33
|
+
debug,
|
|
34
|
+
mageRoot: baseConfig.containerMagentoDir,
|
|
35
|
+
isXDebug2,
|
|
36
|
+
hostMachine
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throw new UnknownError(`Unexpected error accrued during xdebug.ini config creation\n\n${e}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
module.exports = createPhpDebugConfig;
|
|
@@ -7,10 +7,8 @@ const setConfigFile = require('../../util/set-config');
|
|
|
7
7
|
const createPhpFpmConfig = () => ({
|
|
8
8
|
title: 'Setting php-fpm config',
|
|
9
9
|
task: async (ctx) => {
|
|
10
|
-
const { config: { php } } = ctx;
|
|
11
|
-
const
|
|
12
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
-
const port = isNativeLinux ? ctx.ports.fpm : 9000;
|
|
10
|
+
const { config: { php }, isDockerDesktop } = ctx;
|
|
11
|
+
const port = !isDockerDesktop ? ctx.ports.fpm : 9000;
|
|
14
12
|
|
|
15
13
|
try {
|
|
16
14
|
await setConfigFile({
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const fs = require('fs');
|
|
4
3
|
const setConfigFile = require('../../util/set-config');
|
|
@@ -19,8 +18,8 @@ const createSSLTerminatorConfig = () => ({
|
|
|
19
18
|
overridenConfiguration,
|
|
20
19
|
baseConfig
|
|
21
20
|
},
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
debug,
|
|
22
|
+
isDockerDesktop
|
|
24
23
|
} = ctx;
|
|
25
24
|
|
|
26
25
|
const {
|
|
@@ -65,10 +64,8 @@ const createSSLTerminatorConfig = () => ({
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
71
|
-
const hostPort = isNativeLinux ? ports.sslTerminator : 80;
|
|
67
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
68
|
+
const hostPort = !isDockerDesktop ? ports.sslTerminator : 80;
|
|
72
69
|
|
|
73
70
|
try {
|
|
74
71
|
await setConfigFile({
|
|
@@ -17,8 +17,7 @@ const createVarnishConfig = () => ({
|
|
|
17
17
|
cacheDir
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
platform
|
|
20
|
+
isDockerDesktop
|
|
22
21
|
} = ctx;
|
|
23
22
|
|
|
24
23
|
const {
|
|
@@ -27,9 +26,6 @@ const createVarnishConfig = () => ({
|
|
|
27
26
|
}
|
|
28
27
|
} = overridenConfiguration;
|
|
29
28
|
|
|
30
|
-
const isLinux = platform === 'linux';
|
|
31
|
-
const isNativeLinux = isLinux && !isWsl;
|
|
32
|
-
|
|
33
29
|
try {
|
|
34
30
|
await setConfigFile({
|
|
35
31
|
configPathname: path.join(
|
|
@@ -40,8 +36,9 @@ const createVarnishConfig = () => ({
|
|
|
40
36
|
template: varnish.configTemplate,
|
|
41
37
|
overwrite: true,
|
|
42
38
|
templateArgs: {
|
|
43
|
-
hostMachine:
|
|
44
|
-
nginxPort: ports.app
|
|
39
|
+
hostMachine: !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal',
|
|
40
|
+
nginxPort: ports.app,
|
|
41
|
+
healthCheck: varnish.healthCheck
|
|
45
42
|
}
|
|
46
43
|
});
|
|
47
44
|
} catch (e) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const createMariaDBConfig = require('./create-mariadb-config');
|
|
2
2
|
const createNginxConfig = require('./create-nginx-config');
|
|
3
3
|
const createPhpConfig = require('./create-php-config');
|
|
4
|
+
const createPhpDebugConfig = require('./create-php-debug-config');
|
|
4
5
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
5
6
|
const createPhpStormConfig = require('./create-phpstorm-config');
|
|
6
7
|
const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
|
|
@@ -17,6 +18,7 @@ const prepareFileSystem = () => ({
|
|
|
17
18
|
createNginxConfig(),
|
|
18
19
|
createPhpFpmConfig(),
|
|
19
20
|
createPhpConfig(),
|
|
21
|
+
createPhpDebugConfig(),
|
|
20
22
|
createPhpStormConfig(),
|
|
21
23
|
createVSCodeConfig(),
|
|
22
24
|
createVarnishConfig(),
|
|
@@ -7,10 +7,8 @@ module.exports = () => ({
|
|
|
7
7
|
title: 'Configuring Elasticsearch',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
9
|
task: async (ctx, task) => {
|
|
10
|
-
const { ports, databaseConnection } = ctx;
|
|
11
|
-
const
|
|
12
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
|
+
const { ports, databaseConnection, isDockerDesktop } = ctx;
|
|
11
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
14
12
|
await updateTableValues('core_config_data', [
|
|
15
13
|
{ path: 'catalog/search/engine', value: 'elasticsearch7' },
|
|
16
14
|
{ path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
-
const os = require('os');
|
|
3
2
|
const UnknownError = require('../../../errors/unknown-error');
|
|
4
3
|
|
|
5
|
-
const isLinux = os.platform() === 'linux';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
9
6
|
*/
|
|
10
7
|
module.exports = () => ({
|
|
11
8
|
title: 'Flushing Magento redis cache',
|
|
12
|
-
task: async ({ ports, config: { docker } }) => {
|
|
9
|
+
task: async ({ ports, config: { docker }, isDockerDesktop }) => {
|
|
13
10
|
const { redis: { name } } = docker.getContainers(ports);
|
|
14
|
-
const host =
|
|
15
|
-
const port =
|
|
11
|
+
const host = !isDockerDesktop ? 'localhost' : 'host.docker.internal';
|
|
12
|
+
const port = !isDockerDesktop ? '6379' : ports.redis;
|
|
16
13
|
const result = await execAsyncSpawn(`docker exec ${ name } redis-cli -h ${ host } -p ${ port } -n 0 flushdb`);
|
|
17
14
|
|
|
18
15
|
if (!result.trim().includes('OK')) {
|
|
@@ -5,6 +5,8 @@ const UnknownError = require('../../../errors/unknown-error');
|
|
|
5
5
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
6
6
|
const envPhpToJson = require('../../../util/env-php-json');
|
|
7
7
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
8
|
+
const { defaultMagentoDatabase } = require('../../database/default-magento-database');
|
|
9
|
+
const defaultMagentoUser = require('../../database/default-magento-user');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @param {Object} [param0]
|
|
@@ -20,16 +22,14 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
20
22
|
const {
|
|
21
23
|
magentoVersion,
|
|
22
24
|
config: {
|
|
23
|
-
docker,
|
|
24
25
|
magentoConfiguration
|
|
25
26
|
},
|
|
26
27
|
ports,
|
|
27
|
-
databaseConnection
|
|
28
|
+
databaseConnection,
|
|
29
|
+
isDockerDesktop
|
|
28
30
|
} = ctx;
|
|
29
31
|
|
|
30
|
-
const
|
|
31
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
32
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
32
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
33
33
|
|
|
34
34
|
const [tableResponse] = await databaseConnection.query(
|
|
35
35
|
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
@@ -73,8 +73,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
73
73
|
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
const { mariadb: { env } } = docker.getContainers(ports);
|
|
78
76
|
const envPhpData = await envPhpToJson(ctx);
|
|
79
77
|
|
|
80
78
|
const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
|
|
@@ -127,9 +125,9 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
127
125
|
--cache-backend-redis-port='${ ports.redis }' \
|
|
128
126
|
--cache-backend-redis-db='0't \
|
|
129
127
|
--db-host='${ hostMachine }:${ ports.mariadb }' \
|
|
130
|
-
--db-name='${
|
|
131
|
-
--db-user='${
|
|
132
|
-
--db-password='${
|
|
128
|
+
--db-name='${ defaultMagentoDatabase }' \
|
|
129
|
+
--db-user='${ defaultMagentoUser.user }' \
|
|
130
|
+
--db-password='${ defaultMagentoUser.password }' \
|
|
133
131
|
--backend-frontname='${ magentoConfiguration.adminuri }' \
|
|
134
132
|
--no-interaction`;
|
|
135
133
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const { updateTableValues } = require('../../../util/database');
|
|
3
|
-
const getIsWsl = require('../../../util/is-wsl');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -20,18 +18,15 @@ const varnishConfigSetup = () => ({
|
|
|
20
18
|
},
|
|
21
19
|
databaseConnection,
|
|
22
20
|
ports,
|
|
23
|
-
debug
|
|
21
|
+
debug,
|
|
22
|
+
isDockerDesktop
|
|
24
23
|
} = ctx;
|
|
25
24
|
|
|
26
|
-
const isLinux = os.platform() === 'linux';
|
|
27
|
-
const isWsl = await getIsWsl();
|
|
28
|
-
const isNativeLinux = isLinux && !isWsl;
|
|
29
|
-
|
|
30
25
|
if (!debug && varnishEnabled) {
|
|
31
26
|
await updateTableValues('core_config_data', [
|
|
32
27
|
{
|
|
33
28
|
path: 'system/full_page_cache/varnish/backend_host',
|
|
34
|
-
value:
|
|
29
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
35
30
|
},
|
|
36
31
|
{
|
|
37
32
|
path: 'system/full_page_cache/varnish/backend_port',
|
|
@@ -39,7 +34,7 @@ const varnishConfigSetup = () => ({
|
|
|
39
34
|
},
|
|
40
35
|
{
|
|
41
36
|
path: 'system/full_page_cache/varnish/access_list',
|
|
42
|
-
value:
|
|
37
|
+
value: isDockerDesktop ? 'host.docker.internal,localhost' : 'localhost'
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
40
|
path: 'system/full_page_cache/caching_application',
|
|
@@ -4,9 +4,9 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { request } = require('smol-request');
|
|
6
6
|
const KnownError = require('../../../errors/known-error');
|
|
7
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
8
7
|
const { NginxParser } = require('../../../util/nginx-logs-parser');
|
|
9
8
|
const sleep = require('../../../util/sleep');
|
|
9
|
+
const { containerApi } = require('../../docker/containers');
|
|
10
10
|
|
|
11
11
|
const pathToWorkingHealthCheckPhp = path.join(__dirname, '..', '..', 'php', 'working_health_check.php');
|
|
12
12
|
const pathToProjectsHealthCheckPhp = path.join(process.cwd(), 'pub', 'health_check.php');
|
|
@@ -17,19 +17,18 @@ const pathToHealthCheckBackupPhp = path.join(process.cwd(), 'pub', 'health_check
|
|
|
17
17
|
*/
|
|
18
18
|
const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
19
19
|
const { nginx } = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return parsedRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
20
|
+
const parser = new NginxParser(
|
|
21
|
+
'$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'
|
|
22
|
+
);
|
|
23
|
+
const parsedLogs = await containerApi.logs({
|
|
24
|
+
name: nginx.name,
|
|
25
|
+
parser: (line) => parser.parseLine(line)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const healthCheckRequests = parsedLogs
|
|
29
|
+
.filter((line) => line.request.includes('/health_check.php'));
|
|
30
|
+
|
|
31
|
+
return healthCheckRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -39,12 +38,12 @@ const waitingForVarnish = () => ({
|
|
|
39
38
|
title: 'Waiting for Varnish to return code 200',
|
|
40
39
|
skip: (ctx) => ctx.debug
|
|
41
40
|
|| !ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
42
|
-
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
41
|
+
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
42
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.healthCheck,
|
|
43
43
|
task: async (ctx, task) => {
|
|
44
44
|
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
45
45
|
|
|
46
46
|
const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
|
|
47
|
-
|
|
48
47
|
let tries = 0;
|
|
49
48
|
while (tries < 10) {
|
|
50
49
|
try {
|
|
@@ -19,11 +19,10 @@ const updateEnvPHP = () => ({
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const { isDockerDesktop, platform } = ctx;
|
|
22
23
|
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
26
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
25
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
27
26
|
|
|
28
27
|
const useVarnish = (!ctx.debug && ctx.config.overridenConfiguration.configuration.varnish.enabled) ? '1' : '';
|
|
29
28
|
const varnishHost = hostMachine;
|
|
@@ -78,7 +77,7 @@ const updateEnvPHP = () => ({
|
|
|
78
77
|
image: php.image,
|
|
79
78
|
detach: false,
|
|
80
79
|
rm: true,
|
|
81
|
-
user:
|
|
80
|
+
user: platform === 'linux' ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
task.output = result;
|