@scandipwa/magento-scripts 2.0.0-alpha.1 → 2.0.0-alpha.12

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.
Files changed (128) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +5 -0
  4. package/lib/commands/execute.js +2 -57
  5. package/lib/commands/start.js +17 -3
  6. package/lib/commands/status.js +9 -1
  7. package/lib/config/config.js +20 -2
  8. package/lib/config/docker.js +51 -49
  9. package/lib/config/index.js +1 -1
  10. package/lib/config/php/versions/php-7.2.js +1 -0
  11. package/lib/config/php/versions/php-7.3.js +1 -0
  12. package/lib/config/php/versions/php-7.4.js +1 -0
  13. package/lib/config/php/versions/php-8.1.js +1 -0
  14. package/lib/config/php-config.js +4 -3
  15. package/lib/config/services/composer/versions/composer-1.js +8 -0
  16. package/lib/config/services/composer/versions/composer-2.js +8 -0
  17. package/lib/config/services/composer/versions/index.js +4 -0
  18. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  19. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +2 -6
  20. package/lib/config/services/nginx/versions/index.js +3 -0
  21. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  22. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  23. package/lib/config/templates/magentorc.template +6 -5
  24. package/lib/config/templates/php-debug.template.ini +31 -0
  25. package/lib/config/templates/php-fpm.template.conf +1 -2
  26. package/lib/config/templates/php.template.ini +6 -202
  27. package/lib/config/templates/ssl-terminator.template.conf +10 -3
  28. package/lib/config/templates/varnish.template.vcl +20 -13
  29. package/lib/config/varnish/varnish-6-0.js +4 -0
  30. package/lib/config/varnish/varnish-6-6.js +4 -0
  31. package/lib/config/varnish/varnish-7-0.js +4 -0
  32. package/lib/config/versions/magento-2.3.0.js +5 -9
  33. package/lib/config/versions/magento-2.3.1.js +5 -9
  34. package/lib/config/versions/magento-2.3.2-p1.js +5 -9
  35. package/lib/config/versions/magento-2.3.2-p2.js +5 -9
  36. package/lib/config/versions/magento-2.3.2.js +5 -9
  37. package/lib/config/versions/magento-2.3.3-p1.js +5 -9
  38. package/lib/config/versions/magento-2.3.3.js +5 -9
  39. package/lib/config/versions/magento-2.3.4-p1.js +5 -9
  40. package/lib/config/versions/magento-2.3.4-p2.js +5 -9
  41. package/lib/config/versions/magento-2.3.4.js +5 -9
  42. package/lib/config/versions/magento-2.3.5-p1.js +5 -9
  43. package/lib/config/versions/magento-2.3.5-p2.js +5 -9
  44. package/lib/config/versions/magento-2.3.5.js +5 -9
  45. package/lib/config/versions/magento-2.3.6-p1.js +5 -9
  46. package/lib/config/versions/magento-2.3.6.js +5 -9
  47. package/lib/config/versions/magento-2.3.7-p1.js +5 -9
  48. package/lib/config/versions/magento-2.3.7-p2.js +5 -9
  49. package/lib/config/versions/magento-2.3.7-p3.js +5 -9
  50. package/lib/config/versions/magento-2.3.7-p4.js +40 -0
  51. package/lib/config/versions/magento-2.3.7.js +5 -9
  52. package/lib/config/versions/magento-2.4.0-p1.js +5 -9
  53. package/lib/config/versions/magento-2.4.0.js +5 -9
  54. package/lib/config/versions/magento-2.4.1-p1.js +5 -9
  55. package/lib/config/versions/magento-2.4.1.js +5 -9
  56. package/lib/config/versions/magento-2.4.2-p1.js +5 -9
  57. package/lib/config/versions/magento-2.4.2-p2.js +5 -9
  58. package/lib/config/versions/magento-2.4.2.js +5 -9
  59. package/lib/config/versions/magento-2.4.3-p1.js +5 -9
  60. package/lib/config/versions/magento-2.4.3-p2.js +5 -9
  61. package/lib/config/versions/magento-2.4.3-p3.js +42 -0
  62. package/lib/config/versions/magento-2.4.3.js +5 -9
  63. package/lib/config/versions/magento-2.4.4-p1.js +42 -0
  64. package/lib/config/versions/magento-2.4.4.js +5 -9
  65. package/lib/config/versions/magento-2.4.5.js +42 -0
  66. package/lib/tasks/composer/local-auth-json.js +1 -1
  67. package/lib/tasks/database/connect-to-database.js +6 -3
  68. package/lib/tasks/database/create-magento-database.js +5 -2
  69. package/lib/tasks/database/create-magento-user.js +50 -0
  70. package/lib/tasks/database/default-magento-database.js +3 -0
  71. package/lib/tasks/database/default-magento-user.js +7 -0
  72. package/lib/tasks/database/import-dump-to-database.js +3 -2
  73. package/lib/tasks/docker/api.d.ts +25 -1
  74. package/lib/tasks/docker/api.js +31 -1
  75. package/lib/tasks/docker/containers/container-api.d.ts +18 -0
  76. package/lib/tasks/docker/containers/container-api.js +76 -17
  77. package/lib/tasks/docker/containers/tasks.js +32 -1
  78. package/lib/tasks/docker/index.js +6 -1
  79. package/lib/tasks/docker/project-image-builder.js +6 -8
  80. package/lib/tasks/docker/volume/index.js +2 -1
  81. package/lib/tasks/docker/volume/tasks.js +54 -9
  82. package/lib/tasks/docker/volume/volume-api.d.ts +10 -0
  83. package/lib/tasks/docker/volume/volume-api.js +25 -1
  84. package/lib/tasks/execute.js +100 -0
  85. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  86. package/lib/tasks/file-system/create-php-config.js +2 -23
  87. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  88. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  89. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
  90. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
  91. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  92. package/lib/tasks/file-system/index.js +2 -0
  93. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  94. package/lib/tasks/magento/install-magento-project.js +3 -2
  95. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  96. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  97. package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
  98. package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
  99. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  100. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
  101. package/lib/tasks/php/php-container.js +7 -3
  102. package/lib/tasks/php/update-env-php.js +3 -4
  103. package/lib/tasks/requirements/composer-credentials.js +7 -3
  104. package/lib/tasks/requirements/docker/context.js +88 -0
  105. package/lib/tasks/requirements/docker/index.js +110 -19
  106. package/lib/tasks/requirements/docker/install.js +21 -7
  107. package/lib/tasks/requirements/docker/permissions.js +2 -11
  108. package/lib/tasks/requirements/docker/running-status.js +94 -24
  109. package/lib/tasks/requirements/docker/version.js +1 -0
  110. package/lib/tasks/requirements/index.js +0 -2
  111. package/lib/tasks/requirements/php-version.js +4 -2
  112. package/lib/tasks/start.js +28 -7
  113. package/lib/tasks/status/index.js +13 -11
  114. package/lib/tasks/stop.js +2 -0
  115. package/lib/util/config-file-validator.js +2 -0
  116. package/lib/util/execute-in-container.js +63 -0
  117. package/lib/util/systemctl.js +62 -13
  118. package/package.json +4 -3
  119. package/typings/context.d.ts +7 -0
  120. package/typings/index.d.ts +38 -1
  121. package/lib/tasks/execute/index.js +0 -26
  122. package/lib/tasks/requirements/dependency/arch.js +0 -50
  123. package/lib/tasks/requirements/dependency/centos.js +0 -36
  124. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  125. package/lib/tasks/requirements/dependency/index.js +0 -33
  126. package/lib/tasks/requirements/dependency/mac.js +0 -124
  127. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
  128. package/yarn-error.log +0 -9660
package/exec.js ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+
3
+ const getLatestVersion = require('@scandipwa/scandipwa-dev-utils/latest-version');
4
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
5
+ const semver = require('semver');
6
+ const isInstalledGlobally = require('is-installed-globally');
7
+ const isRunningRoot = require('./lib/util/is-running-root');
8
+ const { executeTask } = require('./lib/tasks/execute');
9
+
10
+ if (isRunningRoot()) {
11
+ logger.error('Root privileges detected!');
12
+ console.log(`
13
+ We detected that you are running ${ logger.style.misc('magento-scripts') } as root user.
14
+ We cannot allow you to run ${ logger.style.misc('magento-scripts') } with root privileges, this will only cause more problems.
15
+
16
+ If you are experiencing problems with ${ logger.style.misc('Docker') } or ${ logger.style.misc('Magento') } setup, running ${ logger.style.misc('magento-scripts') } as root will not solve those problems.
17
+ `);
18
+
19
+ process.exit(1);
20
+ }
21
+
22
+ process.title = 'magento-scripts';
23
+
24
+ const newVersionIsAPatch = (latestVersion, currentVersion) => {
25
+ const latestVersionParsed = semver.parse(latestVersion);
26
+ const currentVersionParsed = semver.parse(currentVersion);
27
+
28
+ return latestVersionParsed.major === currentVersionParsed.major
29
+ && latestVersionParsed.minor === currentVersionParsed.minor
30
+ && latestVersionParsed.patch !== currentVersionParsed.patch;
31
+ };
32
+
33
+ (async () => {
34
+ const { version: currentVersion, name } = require('./package.json');
35
+ try {
36
+ const latestVersion = await getLatestVersion(name);
37
+
38
+ if (semver.gt(latestVersion, currentVersion)) {
39
+ const isNewVersionAPath = newVersionIsAPatch(latestVersion, currentVersion);
40
+
41
+ let message = [];
42
+
43
+ if (isNewVersionAPath) {
44
+ message = [
45
+ `A patch for ${ logger.style.misc(name) } is available!`,
46
+ `We recommend to update to latest version ${ logger.style.misc(latestVersion) }!`,
47
+ `-> ${ logger.style.command(`npm i ${ isInstalledGlobally ? '-g ' : '' }${ name }@${ latestVersion }`) }`
48
+ ];
49
+ } else {
50
+ message = [
51
+ `${ isInstalledGlobally ? 'Global module' : 'Module' } ${ logger.style.misc(name) } (${currentVersion}) is out-dated.`,
52
+ `Please upgrade it to latest version ${ logger.style.misc(latestVersion) }.`,
53
+ `You can do it by running the following command: ${ logger.style.command(`npm i ${ isInstalledGlobally ? '-g ' : '' }${ name }@${ latestVersion }`) }.`
54
+ ];
55
+ }
56
+
57
+ process.isOutOfDateVersion = true;
58
+ process.isOutOfDateVersionMessage = message;
59
+ }
60
+ } catch (e) {
61
+ logger.warn(`Package ${ logger.style.misc(name) } is not yet published.`);
62
+ logger.log(); // add empty line
63
+ }
64
+
65
+ const [containername, ...commands] = process.argv.slice(2);
66
+
67
+ return executeTask({
68
+ containername,
69
+ commands
70
+ });
71
+ })();
package/index.js CHANGED
@@ -13,7 +13,7 @@ if (isRunningRoot()) {
13
13
  We detected that you are running ${ logger.style.misc('magento-scripts') } as root user.
14
14
  We cannot allow you to run ${ logger.style.misc('magento-scripts') } with root privileges, this will only cause more problems.
15
15
 
16
- If you are experiencing problems with ${ logger.style.misc('Docker') }, ${ logger.style.misc('PHPBrew') } and ${ logger.style.misc('PHP') } compilation or ${ logger.style.misc('Magento') } setup, running ${ logger.style.misc('magento-scripts') } as root will not solve those problems.
16
+ If you are experiencing problems with ${ logger.style.misc('Docker') } or ${ logger.style.misc('Magento') } setup, running ${ logger.style.misc('magento-scripts') } as root will not solve those problems.
17
17
  `);
18
18
 
19
19
  process.exit(1);
@@ -46,6 +46,11 @@ module.exports = (yargs) => {
46
46
  .addLine(`Available shortcuts: magento -> ${logger.style.command('m')}, composer -> ${logger.style.command('c')}`)
47
47
  .addEmptyLine();
48
48
 
49
+ block
50
+ .addLine(`Execute into any service: ${logger.style.command('exec <service name>')}`)
51
+ .addLine(`Execute into PHP container: ${logger.style.command('exec php')}`)
52
+ .addEmptyLine();
53
+
49
54
  if (ctx.config.overridenConfiguration.configuration.varnish.enabled) {
50
55
  block.addLine(`Clear Varnish cache: ${logger.style.command('cvc')}`);
51
56
  }
@@ -1,11 +1,4 @@
1
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const { Listr } = require('listr2');
3
- const checkConfigurationFile = require('../config/check-configuration-file');
4
- const getProjectConfiguration = require('../config/get-project-configuration');
5
- const executeInContainer = require('../tasks/execute');
6
- const getMagentoVersionConfig = require('../config/get-magento-version-config');
7
- const { checkRequirements } = require('../tasks/requirements');
8
- const { getCachedPorts } = require('../config/get-port-config');
1
+ const { executeTask } = require('../tasks/execute');
9
2
 
10
3
  /**
11
4
  * @param {import('yargs')} yargs
@@ -26,55 +19,7 @@ Available containers:
26
19
  - sslTerminator`);
27
20
  },
28
21
  async (argv) => {
29
- const tasks = new Listr([
30
- checkRequirements(),
31
- getMagentoVersionConfig(),
32
- checkConfigurationFile(),
33
- getProjectConfiguration(),
34
- getCachedPorts()
35
- ], {
36
- concurrent: false,
37
- exitOnError: true,
38
- ctx: { throwMagentoVersionMissing: true },
39
- rendererOptions: { collapse: false, clearOutput: true }
40
- });
41
-
42
- let ctx;
43
- try {
44
- ctx = await tasks.run();
45
- } catch (e) {
46
- logger.error(e.message || e);
47
- process.exit(1);
48
- }
49
- const containers = ctx.config.docker.getContainers(ctx.ports);
50
- const services = Object.keys(containers);
51
-
52
- if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
53
- const container = containers[argv.containername]
54
- ? containers[argv.containername]
55
- : Object.entries(containers).find(([key]) => key.includes(argv.containername))[1];
56
-
57
- if (argv.commands.length === 0) {
58
- // if we have default connect command then use it
59
- if (container.connectCommand) {
60
- // eslint-disable-next-line no-param-reassign
61
- argv.commands = container.connectCommand;
62
- } else {
63
- // otherwise fall back to bash (if it exists inside container)
64
- argv.commands.push('bash');
65
- }
66
- }
67
-
68
- logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands[0])})`);
69
- await executeInContainer({
70
- containerName: container.name,
71
- commands: argv.commands
72
- });
73
-
74
- return;
75
- }
76
-
77
- logger.error(`No container found "${argv.containername}"`);
22
+ await executeTask(argv);
78
23
  }
79
24
  );
80
25
  };
@@ -22,6 +22,7 @@ const reportErrors = async (errors) => {
22
22
  const path = (error.path && ` Error path: ${error.path} `) || '';
23
23
  if (error instanceof UnknownError || error instanceof KnownError) {
24
24
  logger.error(error.message);
25
+ logger.error(error.stack);
25
26
  if (error instanceof UnknownError) {
26
27
  await googleAnalytics.trackError(`Unknown Error:${path}${error.stack}`);
27
28
  } else {
@@ -29,9 +30,11 @@ const reportErrors = async (errors) => {
29
30
  }
30
31
  } else if (error instanceof Error) {
31
32
  logger.error(error.message);
33
+ logger.error(error.stack);
32
34
  await googleAnalytics.trackError(`Regular Error:${path}${error.message}`);
33
35
  } else {
34
36
  logger.error(error);
37
+ logger.error(error.stack);
35
38
  await googleAnalytics.trackError(`Non Error:${path}${error}`); // track non-errors throws
36
39
  }
37
40
  }
@@ -83,6 +86,16 @@ module.exports = (yargs) => {
83
86
  describe: 'Enable verbose logging',
84
87
  type: 'boolean',
85
88
  default: false
89
+ })
90
+ .option('pull-images', {
91
+ describe: 'Pull Docker images',
92
+ type: 'boolean',
93
+ default: false
94
+ })
95
+ .option('reset-global-config', {
96
+ describe: 'Reset global magento-scripts configuration',
97
+ type: 'boolean',
98
+ default: false
86
99
  }),
87
100
  async (args = {}) => {
88
101
  /**
@@ -170,10 +183,11 @@ module.exports = (yargs) => {
170
183
  );
171
184
  logger.log('');
172
185
 
173
- if (!analytics && tasks.err && tasks.err.length > 0) {
174
- logger.warn('You have disabled analytics, but we\'ve encountered errors during startup!');
186
+ if (tasks.err && tasks.err.length > 0) {
187
+ logger.warn('During the start, we encountered some errors that have not impacted the start-up process!');
188
+ logger.log('');
175
189
  for (const err of tasks.err) {
176
- logger.error(`${err.path}\n${err.message}\n\n${err.stack}`);
190
+ logger.error(`Error path: ${err.path}\nError message: ${err.message}\n\nError stack: ${err.stack}`);
177
191
  }
178
192
  }
179
193
 
@@ -9,6 +9,7 @@ const { statusContainers } = require('../tasks/docker/containers');
9
9
  const getProjectConfiguration = require('../config/get-project-configuration');
10
10
  const checkConfigurationFile = require('../config/check-configuration-file');
11
11
  const checkPHPVersion = require('../tasks/requirements/php-version');
12
+ const { getComposerVersionTask } = require('../tasks/composer');
12
13
 
13
14
  /**
14
15
  * @param {import('yargs')} yargs
@@ -21,7 +22,14 @@ module.exports = (yargs) => {
21
22
  checkConfigurationFile(),
22
23
  getProjectConfiguration(),
23
24
  getCachedPorts(),
24
- checkPHPVersion(),
25
+ {
26
+ task: (ctx, task) => task.newListr([
27
+ checkPHPVersion(),
28
+ getComposerVersionTask()
29
+ ], {
30
+ concurrent: true
31
+ })
32
+ },
25
33
  statusContainers()
26
34
  ], {
27
35
  concurrent: false,
@@ -2,6 +2,16 @@ const Conf = require('conf');
2
2
 
3
3
  const pkg = require('../../package.json');
4
4
 
5
+ /**
6
+ * @typedef ProjectConfig
7
+ * @prop {String} [createdAt]
8
+ * @prop {String} [prefix]
9
+ * @prop {Boolean} debug
10
+ */
11
+
12
+ /**
13
+ * @type {import('conf').default<Record<string, ProjectConfig>>}
14
+ */
5
15
  const projectsConfig = new Conf({
6
16
  configName: 'projects',
7
17
  projectName: 'create-magento-app',
@@ -10,6 +20,12 @@ const projectsConfig = new Conf({
10
20
  });
11
21
  const projectKey = process.cwd();
12
22
 
23
+ const setProjectConfig = (key, value) => {
24
+ projectsConfig.set(`${projectKey}.${key}`, value);
25
+ };
26
+
27
+ const getProjectConfig = () => projectsConfig.get(projectKey);
28
+
13
29
  const getProjectsFromProjectKeys = (path, project) => {
14
30
  if (project.createdAt) {
15
31
  return { [path]: project };
@@ -21,7 +37,7 @@ const getProjectsFromProjectKeys = (path, project) => {
21
37
  };
22
38
  /**
23
39
  *
24
- * @returns {Record<string, { createdAt?: string, prefix?: string}>}
40
+ * @returns {Record<string, ProjectConfig>}
25
41
  */
26
42
  const getProjects = () => {
27
43
  const projects = {};
@@ -45,5 +61,7 @@ const getProjects = () => {
45
61
  module.exports = {
46
62
  projectsConfig,
47
63
  projectKey,
48
- getProjects
64
+ getProjects,
65
+ setProjectConfig,
66
+ getProjectConfig
49
67
  };
@@ -5,6 +5,8 @@ const { isIpAddress } = require('../util/ip');
5
5
 
6
6
  const systeminformation = require('systeminformation');
7
7
  const { deepmerge } = require('../util/deepmerge');
8
+ const defaultEsEnv = require('./services/elasticsearch/default-es-env');
9
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
8
10
 
9
11
  /**
10
12
  *
@@ -23,7 +25,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
23
25
  varnish
24
26
  } = configuration;
25
27
 
26
- const php = getPhpConfig(configuration, baseConfig);
28
+ const php = getPhpConfig(overridenConfiguration, baseConfig);
27
29
  const {
28
30
  prefix,
29
31
  magentoDir,
@@ -52,51 +54,54 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
52
54
  }
53
55
  };
54
56
 
55
- const isLinux = ctx.platform === 'linux';
56
- const { isWsl } = ctx;
57
- const isNotNativeLinux = (!isLinux || isWsl);
57
+ const { isDockerDesktop } = ctx;
58
58
 
59
- if (!isLinux) {
59
+ if (isDockerDesktop) {
60
60
  /**
61
- * When CMA is running in non-native linux environment,
62
- * we need also create named volumes for nginx to avoid performance penalty
61
+ * When CMA is running with Docker Desktop,
62
+ * we need create named volumes to avoid performance penalty
63
63
  */
64
64
  volumes.php = {
65
65
  name: `${ prefix }_project-data`,
66
+ driver: 'local',
66
67
  opt: {
67
- type: 'nfs',
68
+ type: 'none',
68
69
  device: path.join(magentoDir),
69
70
  o: 'bind'
70
71
  }
71
72
  };
72
73
  volumes.nginx = {
73
74
  name: `${ prefix }_nginx-data`,
75
+ driver: 'local',
74
76
  opt: {
75
- type: 'nfs',
77
+ type: 'none',
76
78
  device: path.join(cacheDir, 'nginx', 'conf.d'),
77
79
  o: 'bind'
78
80
  }
79
81
  };
80
82
  volumes.appPub = {
81
83
  name: `${ prefix }_pub-data`,
84
+ driver: 'local',
82
85
  opt: {
83
- type: 'nfs',
86
+ type: 'none',
84
87
  device: path.join(magentoDir, 'pub'),
85
88
  o: 'bind'
86
89
  }
87
90
  };
88
91
  volumes.appSetup = {
89
92
  name: `${ prefix }_setup-data`,
93
+ driver: 'local',
90
94
  opt: {
91
- type: 'nfs',
95
+ type: 'none',
92
96
  device: path.join(magentoDir, 'setup'),
93
97
  o: 'bind'
94
98
  }
95
99
  };
96
100
  volumes.sslTerminator = {
97
101
  name: `${ prefix }_ssl-terminator-data`,
102
+ driver: 'local',
98
103
  opt: {
99
- type: 'nfs',
104
+ type: 'none',
100
105
  device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
101
106
  o: 'bind'
102
107
  }
@@ -105,8 +110,9 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
105
110
  if (varnish.enabled) {
106
111
  volumes.varnish = {
107
112
  name: `${ prefix }_varnish-data`,
113
+ driver: 'local',
108
114
  opt: {
109
- type: 'nfs',
115
+ type: 'none',
110
116
  device: path.join(cacheDir, 'varnish'),
111
117
  o: 'bind'
112
118
  }
@@ -121,23 +127,23 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
121
127
  const dockerConfig = {
122
128
  php: {
123
129
  _: 'PHP',
124
- ports: isNotNativeLinux ? [
130
+ ports: isDockerDesktop ? [
125
131
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
126
132
  ] : [],
127
133
  forwardedPorts: [
128
- isNotNativeLinux
134
+ isDockerDesktop
129
135
  ? `127.0.0.1:${ ports.fpm }:9000`
130
136
  : `127.0.0.1:${ ports.fpm }`
131
137
  ],
132
- network: isNotNativeLinux ? network.name : 'host',
138
+ network: isDockerDesktop ? network.name : 'host',
133
139
  mountVolumes: [
134
- `${ isLinux ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
140
+ `${ !isDockerDesktop ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
135
141
  `${ volumes.composer_home.name }:/composer/home`,
136
142
  `${ php.iniPath }:/usr/local/etc/php/php.ini`,
137
143
  `${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
138
- ],
144
+ ].concat(ctx.debug ? [`${ php.debugIniPath }:/usr/local/etc/php/conf.d/00-xdebug.ini`] : []),
139
145
  env: {
140
- COMPOSER_AUTH: process.env.COMPOSER_AUTH || '',
146
+ COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || '',
141
147
  COMPOSER_HOME: '/composer/home'
142
148
  },
143
149
  restart: 'on-failure:5',
@@ -149,15 +155,15 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
149
155
  ],
150
156
  name: `${ prefix }_php`,
151
157
  connectCommand: ['/bin/sh'],
152
- user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
158
+ user: ((ctx.platform === 'linux' && isDockerDesktop) || !isDockerDesktop) ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
153
159
  },
154
160
  sslTerminator: {
155
161
  _: 'SSL Terminator (Nginx)',
156
- ports: isNotNativeLinux ? [
162
+ ports: isDockerDesktop ? [
157
163
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.sslTerminator }:80`
158
164
  ] : [],
159
165
  forwardedPorts: [
160
- isNotNativeLinux
166
+ isDockerDesktop
161
167
  ? `127.0.0.1:${ ports.sslTerminator }:80`
162
168
  : `127.0.0.1:${ ports.sslTerminator }`
163
169
  ],
@@ -168,21 +174,21 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
168
174
  * Mount volumes directly on linux
169
175
  */
170
176
  mountVolumes: [
171
- `${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
177
+ `${ !isDockerDesktop ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
172
178
  ],
173
179
  restart: 'on-failure:5',
174
- network: isNotNativeLinux ? network.name : 'host',
180
+ network: isDockerDesktop ? network.name : 'host',
175
181
  image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
176
182
  name: `${ prefix }_ssl-terminator`,
177
183
  command: "nginx -g 'daemon off;'"
178
184
  },
179
185
  nginx: {
180
186
  _: 'Nginx',
181
- ports: isNotNativeLinux ? [
187
+ ports: isDockerDesktop ? [
182
188
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.app }:80`
183
189
  ] : [],
184
190
  forwardedPorts: [
185
- isNotNativeLinux
191
+ isDockerDesktop
186
192
  ? `127.0.0.1:${ ports.app }:80`
187
193
  : `127.0.0.1:${ ports.app }`
188
194
  ],
@@ -192,7 +198,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
192
198
  /**
193
199
  * Mount volumes directly on linux
194
200
  */
195
- mountVolumes: isLinux ? [
201
+ mountVolumes: !isDockerDesktop ? [
196
202
  `${ cacheDir }/nginx/conf.d:/etc/nginx/conf.d`,
197
203
  `${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
198
204
  `${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
@@ -202,8 +208,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
202
208
  `${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
203
209
  ],
204
210
  restart: 'on-failure:5',
205
- // TODO: use connect instead
206
- network: isNotNativeLinux ? network.name : 'host',
211
+ network: isDockerDesktop ? network.name : 'host',
207
212
  image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
208
213
  name: `${ prefix }_nginx`,
209
214
  command: "nginx -g 'daemon off;'"
@@ -216,7 +221,6 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
216
221
  ports: [`127.0.0.1:${ ports.redis }:6379`],
217
222
  forwardedPorts: [`127.0.0.1:${ ports.redis }:6379`],
218
223
  mounts: [`source=${ volumes.redis.name },target=/data`],
219
- // TODO: use connect instead
220
224
  network: network.name,
221
225
  image: `${ redis.version ? `redis:${ redis.version }` : redis.image }`,
222
226
  name: `${ prefix }_redis`,
@@ -234,22 +238,18 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
234
238
  `${ path.join(baseConfig.cacheDir, 'mariadb.cnf') }:/etc/mysql/my.cnf`
235
239
  ],
236
240
  env: {
237
- MARIADB_PORT: 3306,
238
- MARIADB_ROOT_PASSWORD: 'scandipwa',
239
- MARIADB_USER: 'magento',
240
- MARIADB_PASSWORD: 'magento',
241
- MARIADB_DATABASE: 'magento'
241
+ MARIADB_ROOT_PASSWORD: 'scandipwa'
242
242
  },
243
- command: [
244
- '--log_bin_trust_function_creators=1'
245
- ]
246
- .join(' '),
243
+ command: '--log_bin_trust_function_creators=1',
247
244
  securityOptions: [
248
245
  'seccomp=unconfined'
249
246
  ],
250
247
  network: network.name,
251
248
  image: `${ mariadb.version ? `mariadb:${ mariadb.version }` : mariadb.image }`,
252
- name: `${ prefix }_mariadb`
249
+ name: `${ prefix }_mariadb`,
250
+ description: `To connect to MariaDB you can use the following users:
251
+ - ${ logger.style.command('root') }@${ logger.style.command('scandipwa') }
252
+ - ${ logger.style.command('magento') }@${ logger.style.command('magento') }`
253
253
  },
254
254
  elasticsearch: {
255
255
  _: 'ElasticSearch',
@@ -259,10 +259,12 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
259
259
  ports: [`127.0.0.1:${ ports.elasticsearch }:9200`],
260
260
  forwardedPorts: [`127.0.0.1:${ ports.elasticsearch }:9200`],
261
261
  mounts: [`source=${ volumes.elasticsearch.name },target=/usr/share/elasticsearch/data`],
262
- env: deepmerge({
262
+ env: deepmerge(
263
+ {
263
264
  // https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
264
- 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
265
- }, elasticsearch.env),
265
+ 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
266
+ }, elasticsearch.env || defaultEsEnv
267
+ ),
266
268
  network: network.name,
267
269
  image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
268
270
  name: `${ prefix }_elasticsearch`
@@ -270,7 +272,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
270
272
  };
271
273
 
272
274
  if (ssl.enabled) {
273
- dockerConfig.nginx.ports.push(
275
+ dockerConfig.sslTerminator.ports.push(
274
276
  `${isIpAddress(host) ? host : '127.0.0.1'}:443:443`
275
277
  );
276
278
  }
@@ -281,13 +283,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
281
283
  image: `${ varnish.version ? `varnish:${ varnish.version }` : varnish.image }`,
282
284
  name: `${ prefix }_varnish`,
283
285
  mountVolumes: [
284
- `${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
286
+ `${ !isDockerDesktop ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
285
287
  ],
286
- ports: isNotNativeLinux ? [
288
+ ports: isDockerDesktop ? [
287
289
  `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.varnish }:80`
288
290
  ] : [],
289
291
  forwardedPorts: [
290
- isNotNativeLinux
292
+ isDockerDesktop
291
293
  ? `127.0.0.1:${ ports.varnish }:80`
292
294
  : `127.0.0.1:${ ports.varnish }`
293
295
  ],
@@ -295,9 +297,9 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
295
297
  VARNISH_SIZE: '2G'
296
298
  },
297
299
  restart: 'on-failure:30',
298
- network: isNotNativeLinux ? network.name : 'host',
300
+ network: isDockerDesktop ? network.name : 'host',
299
301
  // eslint-disable-next-line max-len
300
- command: `/bin/bash -c "varnishd -a :${ isNotNativeLinux ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
302
+ command: `/bin/bash -c "varnishd -a :${ isDockerDesktop ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s Cache=malloc,2048m -s Transient=malloc,512m -p http_resp_hdr_len=70000 -p http_resp_size=100000 && varnishlog"`,
301
303
  tmpfs: [
302
304
  '/var/lib/varnish:exec'
303
305
  ]
@@ -56,7 +56,7 @@ module.exports = {
56
56
  );
57
57
 
58
58
  return {
59
- php: getPhpConfig(overridenConfiguration.configuration, newBaseConfig),
59
+ php: getPhpConfig(overridenConfiguration, newBaseConfig),
60
60
  docker: await getDockerConfig(ctx, overridenConfiguration, newBaseConfig),
61
61
  magentoConfiguration: getMagentoConfig(overridenConfiguration.magento),
62
62
  baseConfig: newBaseConfig,
@@ -14,6 +14,7 @@ const php72 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php73 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php74 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -14,6 +14,7 @@ const php81 = ({
14
14
  debugImage: `${ baseImage }-debug`,
15
15
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
16
16
  fpmConfigTemplate: path.join(templateDir || '', 'php-fpm.template.conf'),
17
+ debugTemplate: path.join(templateDir || '', 'php-debug.template.ini'),
17
18
  extensions: {
18
19
  xdebug,
19
20
  ...extensions
@@ -5,17 +5,18 @@ const path = require('path');
5
5
  * @param {import('../../typings/context').ListrContext['config']['baseConfig']} baseConfig
6
6
  */
7
7
  module.exports = (overridenConfiguration, baseConfig) => {
8
- const { php } = overridenConfiguration;
8
+ const { configuration: { php } } = overridenConfiguration;
9
9
 
10
10
  const { cacheDir } = baseConfig;
11
11
 
12
12
  const phpConfiguration = {
13
13
  iniPath: path.join(cacheDir, 'php.ini'),
14
14
  iniTemplatePath: php.configTemplate,
15
+ debugIniPath: path.join(cacheDir, 'xdebug.ini'),
16
+ debugTemplatePath: php.debugTemplate,
15
17
  fpmTemplatePath: php.fpmConfigTemplate,
16
18
  fpmConfPath: path.join(cacheDir, 'php-fpm.conf'),
17
- extensions: php.extensions,
18
- version: php.version
19
+ extensions: php.extensions
19
20
  };
20
21
 
21
22
  return phpConfiguration;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ComposerConfiguration}
3
+ */
4
+ const composer1 = () => ({
5
+ version: '1'
6
+ });
7
+
8
+ module.exports = composer1;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @returns {import('../../../../../typings/index').ComposerConfiguration}
3
+ */
4
+ const composer2 = () => ({
5
+ version: '2'
6
+ });
7
+
8
+ module.exports = composer2;
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ composer1: require('./composer-1'),
3
+ composer2: require('./composer-2')
4
+ };