@scandipwa/magento-scripts 2.4.0-alpha.0 → 2.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/exec.js +2 -2
  2. package/index.js +1 -0
  3. package/lib/commands/cli.js +17 -19
  4. package/lib/commands/execute.js +8 -4
  5. package/lib/commands/start.js +0 -6
  6. package/lib/config/docker.js +196 -79
  7. package/lib/config/get-project-configuration.js +0 -5
  8. package/lib/config/php-config.js +4 -0
  9. package/lib/config/port-config.js +47 -10
  10. package/lib/config/services/composer/versions/composer-2.8.js +1 -1
  11. package/lib/config/services/elasticsearch/default-es-env.js +1 -1
  12. package/lib/config/services/elasticsearch/versions/elasticsearch-8.17.js +14 -0
  13. package/lib/config/services/elasticsearch/versions/index.js +3 -1
  14. package/lib/config/services/mariadb/versions/index.js +3 -1
  15. package/lib/config/services/mariadb/versions/mariadb-10.2.js +3 -1
  16. package/lib/config/services/mariadb/versions/mariadb-10.3.js +3 -1
  17. package/lib/config/services/mariadb/versions/mariadb-10.4.js +3 -1
  18. package/lib/config/services/mariadb/versions/mariadb-10.6.js +3 -1
  19. package/lib/config/services/mariadb/versions/mariadb-11.4.js +11 -0
  20. package/lib/config/services/mariadb/versions/mariadb-11.6.js +11 -0
  21. package/lib/config/services/opensearch/default-os-env.js +1 -1
  22. package/lib/config/services/opensearch/versions/index.js +3 -1
  23. package/lib/config/services/opensearch/versions/opensearch-2.19.js +14 -0
  24. package/lib/config/services/php/extensions/ftp.js +7 -0
  25. package/lib/config/services/php/extensions/xdebug.js +1 -0
  26. package/lib/config/services/php/versions/index.js +2 -1
  27. package/lib/config/services/php/versions/php-7.2.js +0 -1
  28. package/lib/config/services/php/versions/php-7.3.js +0 -1
  29. package/lib/config/services/php/versions/php-7.4.js +0 -1
  30. package/lib/config/services/php/versions/php-8.1.js +4 -2
  31. package/lib/config/services/php/versions/php-8.2.js +1 -2
  32. package/lib/config/services/php/versions/php-8.3.js +32 -0
  33. package/lib/config/services/redis/index.js +6 -1
  34. package/lib/config/services/redis/valkey-8.0.js +8 -0
  35. package/lib/config/services/redis/valkey-8.1.js +8 -0
  36. package/lib/config/services/varnish/varnish-6-0.js +1 -1
  37. package/lib/config/services/varnish/varnish-6-6.js +1 -1
  38. package/lib/config/services/varnish/varnish-7-0.js +1 -1
  39. package/lib/config/services/varnish/varnish-7-1.js +1 -1
  40. package/lib/config/services/varnish/varnish-7-3.js +1 -1
  41. package/lib/config/services/varnish/varnish-7-4.js +1 -1
  42. package/lib/config/services/varnish/varnish-7-5.js +1 -1
  43. package/lib/config/services/varnish/varnish-7-6.js +1 -1
  44. package/lib/config/templates/nginx.template.conf +32 -9
  45. package/lib/config/templates/php-fpm.template.conf +1 -1
  46. package/lib/config/templates/ssl-terminator.template.conf +3 -1
  47. package/lib/config/versions/magento-2.4.4-p13.js +40 -0
  48. package/lib/config/versions/magento-2.4.5-p12.js +40 -0
  49. package/lib/config/versions/magento-2.4.6-p10.js +40 -0
  50. package/lib/config/versions/magento-2.4.7-p4.js +0 -1
  51. package/lib/config/versions/magento-2.4.7-p5.js +41 -0
  52. package/lib/config/versions/magento-2.4.8.js +43 -0
  53. package/lib/tasks/database/create-magento-database.js +6 -4
  54. package/lib/tasks/database/import-remote-db/ssh/index.js +1 -1
  55. package/lib/tasks/database/import-remote-db/ssh/readymage.js +1 -1
  56. package/lib/tasks/database/import-remote-db/ssh/regular-server.js +1 -1
  57. package/lib/tasks/docker/containers/container-api.d.ts +14 -3
  58. package/lib/tasks/docker/containers/container-api.js +16 -9
  59. package/lib/tasks/docker/containers/tasks.js +99 -28
  60. package/lib/tasks/docker/convert-mysql-to-mariadb.js +14 -22
  61. package/lib/tasks/docker/project-image-builder.js +153 -91
  62. package/lib/tasks/docker/system/system-api.d.ts +66 -0
  63. package/lib/tasks/docker/system/system-api.js +28 -1
  64. package/lib/tasks/execute.js +10 -10
  65. package/lib/tasks/file-system/create-nginx-config.js +22 -8
  66. package/lib/tasks/file-system/create-php-debug-config.js +1 -2
  67. package/lib/tasks/file-system/create-php-fpm-debug-config.js +33 -0
  68. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +5 -5
  69. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +2 -2
  70. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +4 -3
  71. package/lib/tasks/file-system/create-ssl-terminator-config.js +46 -7
  72. package/lib/tasks/file-system/index.js +2 -0
  73. package/lib/tasks/magento/install-magento-project.js +40 -24
  74. package/lib/tasks/magento/setup-magento/check-file-permissions.php +32 -0
  75. package/lib/tasks/magento/setup-magento/index.js +2 -0
  76. package/lib/tasks/magento/setup-magento/make-magento-binaries-executable.js +44 -0
  77. package/lib/tasks/magento/setup-magento/setup-file-permissions.js +160 -0
  78. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +0 -1
  79. package/lib/tasks/php/php-container.d.ts +3 -3
  80. package/lib/tasks/php/php-container.js +22 -18
  81. package/lib/tasks/php/update-env-php.js +7 -14
  82. package/lib/tasks/project-config/index.js +0 -3
  83. package/lib/tasks/requirements/cgroup-version.js +69 -0
  84. package/lib/tasks/requirements/elasticsearch-version.js +23 -7
  85. package/lib/tasks/requirements/index.js +3 -0
  86. package/lib/tasks/requirements/opensearch-version.js +5 -5
  87. package/lib/tasks/requirements/searchengine-version.js +1 -2
  88. package/lib/tasks/start.js +2 -13
  89. package/lib/util/dockerfile-builder/build-instructions.js +5 -1
  90. package/lib/util/dockerfile-builder/types.d.ts +1 -1
  91. package/lib/util/execute-in-container.js +14 -8
  92. package/lib/util/get-installed-magento-version.js +60 -2
  93. package/lib/util/portscanner.js +3 -3
  94. package/lib/util/run-composer.js +1 -1
  95. package/lib/util/run-magento.js +2 -1
  96. package/lib/util/run-php.js +2 -1
  97. package/lib/util/set-config.js +4 -2
  98. package/package.json +16 -16
  99. package/typings/context.d.ts +13 -5
  100. package/typings/index.d.ts +10 -5
@@ -35,36 +35,41 @@ const getEnabledExtensionsFromImage = async (imageWithTag) => {
35
35
  }
36
36
 
37
37
  /**
38
- * @type {(builder: DockerFileBuilder, ctx: import('../../../typings/context').ListrContext) => ([extensionName, extensionInstructions]: [string, import('../../../typings').PHPExtensionInstallationInstruction]) => Promise<void>}
38
+ * @type {(builder: DockerFileBuilder, ctx: import('../../../typings/context').ListrContext, [extensionName, extensionInstructions]: [string, import('../../../typings').PHPExtensionInstallationInstruction]) => Promise<void>}
39
39
  */
40
- const addExtensionToBuilder =
41
- (builder, ctx) =>
42
- async ([extensionName, extensionInstructions]) => {
43
- const { command, ...extensionInstructionsWithoutCommand } =
44
- extensionInstructions
45
- let runCommand = ''
46
- if (typeof command === 'string') {
47
- runCommand += ` ${command}`
48
- } else if (typeof command === 'function') {
49
- runCommand += ` ${await Promise.resolve(
50
- command({ ...extensionInstructionsWithoutCommand, ctx })
51
- )}`
52
- } else {
53
- runCommand += ` docker-php-ext-install ${
54
- extensionInstructionsWithoutCommand.name || extensionName
55
- }`
56
- }
57
- builder
58
- .comment(`extension ${extensionName} installation command`)
59
- .run(runCommand.trim())
40
+ const addExtensionToBuilder = async (
41
+ builder,
42
+ ctx,
43
+ [extensionName, extensionInstructions]
44
+ ) => {
45
+ const { command, ...extensionInstructionsWithoutCommand } =
46
+ extensionInstructions
47
+ let runCommand = ''
48
+ if (typeof command === 'string') {
49
+ runCommand += ` ${command}`
50
+ } else if (typeof command === 'function') {
51
+ runCommand += ` ${await Promise.resolve(
52
+ command({ ...extensionInstructionsWithoutCommand, ctx })
53
+ )}`
54
+ } else {
55
+ runCommand += ` docker-php-ext-install ${
56
+ extensionInstructionsWithoutCommand.name || extensionName
57
+ }`
60
58
  }
59
+ builder
60
+ .comment(`extension ${extensionName} installation command`)
61
+ .run(runCommand.trim())
62
+ }
61
63
 
62
64
  /**
63
65
  * @param {import('../../../typings/context').ListrContext} ctx
64
- * @param {{ image: string, tag: string}} param1
66
+ * @param {{ image: string, tag: string, ignorePHPExtensions?: string[] }} param1
65
67
  */
66
- const buildDockerFileInstructions = async (ctx, { image, tag }) => {
67
- const { composer } = ctx.config.overridenConfiguration.configuration
68
+ const buildDockerFileInstructions = async (
69
+ ctx,
70
+ { image, tag, ignorePHPExtensions = [] }
71
+ ) => {
72
+ const { composer, php } = ctx.config.overridenConfiguration.configuration
68
73
  const existingPHPExtensions = await getEnabledExtensionsFromImage(
69
74
  `${image}:${tag}`
70
75
  )
@@ -73,9 +78,11 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
73
78
  formatToJSON: true
74
79
  })
75
80
 
76
- const missingExtensions = Object.entries(
77
- ctx.config.overridenConfiguration.configuration.php.extensions
78
- )
81
+ const missingExtensions = Object.entries(php.extensions)
82
+ .filter(
83
+ ([extensionName]) =>
84
+ !ignorePHPExtensions.includes(extensionName.toLowerCase())
85
+ )
79
86
  .filter(
80
87
  ([extensionName, extensionInstructions]) =>
81
88
  !Object.entries(existingPHPExtensions)
@@ -89,7 +96,6 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
89
96
  .includes(n))
90
97
  )
91
98
  )
92
- .filter(([extensionName]) => extensionName.toLowerCase() !== 'xdebug')
93
99
 
94
100
  const dockerFileInstructions = new DockerFileBuilder()
95
101
  .comment('project image')
@@ -112,8 +118,9 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
112
118
  for (const missingExtensionInstructions of missingExtensions) {
113
119
  await addExtensionToBuilder(
114
120
  dockerFileInstructions,
115
- ctx
116
- )(missingExtensionInstructions)
121
+ ctx,
122
+ missingExtensionInstructions
123
+ )
117
124
  }
118
125
  }
119
126
 
@@ -163,9 +170,8 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
163
170
  }
164
171
 
165
172
  if (!ctx.isDockerDesktop) {
166
- dockerFileInstructions.run(
167
- `chown -R ${os.userInfo().uid}:${os.userInfo().gid} /composer/home`
168
- )
173
+ const { uid, gid } = os.userInfo()
174
+ dockerFileInstructions.run(`chown -R ${uid}:${gid} /composer/home`)
169
175
  }
170
176
 
171
177
  dockerFileInstructions.workDir(ctx.config.baseConfig.containerMagentoDir)
@@ -191,9 +197,10 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
191
197
  })
192
198
  }
193
199
 
194
- if (ctx.config.overridenConfiguration.configuration.newRelic.enabled) {
195
- const { agentVersion, licenseKey } =
196
- ctx.config.overridenConfiguration.configuration.newRelic
200
+ const { newRelic } = ctx.config.overridenConfiguration.configuration
201
+
202
+ if (newRelic && newRelic.enabled) {
203
+ const { agentVersion, licenseKey } = newRelic
197
204
 
198
205
  // eslint-disable-next-line max-len
199
206
  dockerFileInstructions.run('apk add --no-cache gcompat')
@@ -212,79 +219,135 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
212
219
  \\$PHP_INI_DIR/conf.d/newrelic.ini`)
213
220
  }
214
221
 
215
- return dockerFileInstructions
222
+ return dockerFileInstructions.build()
216
223
  }
217
224
 
218
225
  /**
219
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
226
+ * @param {import('../../../typings/context').ListrContext} ctx
227
+ * @param {{ image: string, tag: string }} param1
220
228
  */
221
- const buildProjectImage = () => ({
222
- title: 'Building Project Image',
223
- task: async (ctx, task) => {
224
- const containers = ctx.config.docker.getContainers(ctx.ports)
225
- const [image, tag = 'latest'] =
226
- ctx.config.overridenConfiguration.configuration.php.baseImage.split(
227
- ':'
228
- )
229
- const dockerFileInstructions = await buildDockerFileInstructions(ctx, {
230
- image,
231
- tag
232
- })
229
+ const buildDebugDockerFileInstructions = async (ctx, { image, tag }) => {
230
+ const { php } = ctx.config.overridenConfiguration.configuration
231
+ const existingPHPExtensions = await getEnabledExtensionsFromImage(
232
+ `${image}:${tag}`
233
+ )
233
234
 
234
- try {
235
- await execAsyncSpawn(
236
- `docker build -t ${containers.php.image} -<<EOF
237
- ${dockerFileInstructions.build()}
238
- EOF`,
239
- {
240
- callback: (r) => {
241
- task.output = r
242
- }
243
- }
235
+ const missingExtensions = Object.entries(php.extensions)
236
+ .filter(([extensionName]) => extensionName.toLowerCase() === 'xdebug')
237
+ .filter(
238
+ ([extensionName, extensionInstructions]) =>
239
+ !Object.entries(existingPHPExtensions)
240
+ .map(([n, i]) => [n.toLowerCase(), i])
241
+ .some(
242
+ ([n]) =>
243
+ extensionName === n ||
244
+ (extensionInstructions.alternativeName &&
245
+ extensionInstructions.alternativeName
246
+ .map((s) => s.toLowerCase())
247
+ .includes(n))
248
+ )
249
+ )
250
+
251
+ const dockerFileInstructions = new DockerFileBuilder()
252
+ .comment('project image')
253
+ .from({ image, tag })
254
+
255
+ if (missingExtensions.length > 0) {
256
+ const allDependencies = missingExtensions
257
+ .map(
258
+ ([_extensionName, extensionInstructions]) =>
259
+ extensionInstructions.dependencies || []
244
260
  )
245
- } catch (e) {
246
- throw new KnownError(
247
- `Unexpected error during project image building!\n\n${e}`
261
+ .reduce(
262
+ (acc, val) => acc.concat(val.filter((ex) => !acc.includes(ex))),
263
+ []
264
+ )
265
+
266
+ dockerFileInstructions.run(
267
+ `apk add --no-cache ${allDependencies.join(' ')}`
268
+ )
269
+ for (const missingExtensionInstructions of missingExtensions) {
270
+ await addExtensionToBuilder(
271
+ dockerFileInstructions,
272
+ ctx,
273
+ missingExtensionInstructions
248
274
  )
249
275
  }
250
- },
251
- options: {
252
- bottomBar: 10
253
276
  }
254
- })
277
+
278
+ return dockerFileInstructions.build()
279
+ }
255
280
 
256
281
  /**
257
282
  * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
258
283
  */
259
- const buildDebugProjectImage = () => ({
260
- title: 'Building Debug Project Image',
284
+ const buildProjectImage = () => ({
285
+ title: 'Building Project Images',
261
286
  task: async (ctx, task) => {
262
287
  const containers = ctx.config.docker.getContainers(ctx.ports)
263
- const [image, tag = 'latest'] =
264
- ctx.config.overridenConfiguration.configuration.php.debugImage.split(
265
- ':'
266
- )
267
- const dockerFileInstructions = await buildDockerFileInstructions(ctx, {
268
- image,
269
- tag
270
- })
271
288
 
272
- try {
273
- await execAsyncSpawn(
274
- `docker build -t ${containers.php.debugImage} -<<EOF
275
- ${dockerFileInstructions.build()}
289
+ return task.newListr([
290
+ {
291
+ title: 'Building PHP image',
292
+ task: async () => {
293
+ const [image, tag = 'latest'] =
294
+ ctx.config.overridenConfiguration.configuration.php.baseImage.split(
295
+ ':'
296
+ )
297
+ const dockerFileInstructions =
298
+ await buildDockerFileInstructions(ctx, {
299
+ image,
300
+ tag,
301
+ ignorePHPExtensions: ['xdebug']
302
+ })
303
+
304
+ try {
305
+ await execAsyncSpawn(
306
+ `docker build -t ${containers.php.image} -<<EOF
307
+ ${dockerFileInstructions}
276
308
  EOF`,
277
- {
278
- callback: (r) => {
279
- task.output = r
309
+ {
310
+ callback: (r) => {
311
+ task.output = r
312
+ }
313
+ }
314
+ )
315
+ } catch (e) {
316
+ throw new KnownError(
317
+ `Unexpected error during PHP image building!\n\n${e}`
318
+ )
280
319
  }
281
320
  }
282
- )
283
- } catch (e) {
284
- throw new KnownError(
285
- `Unexpected error during debug project image building!\n\n${e}`
286
- )
287
- }
321
+ },
322
+ {
323
+ title: 'Building PHP with XDebug image',
324
+ task: async () => {
325
+ const [phpImage, phpTag] = containers.php.image.split(':')
326
+ const debugImageInstructions =
327
+ await buildDebugDockerFileInstructions(ctx, {
328
+ image: phpImage,
329
+ tag: phpTag
330
+ })
331
+
332
+ try {
333
+ await execAsyncSpawn(
334
+ `docker build -t ${containers.phpWithXdebug.image} -<<EOF
335
+ ${debugImageInstructions}
336
+ EOF`,
337
+ {
338
+ callback: (r) => {
339
+ task.output = r
340
+ }
341
+ }
342
+ )
343
+ } catch (e) {
344
+ throw new KnownError(
345
+ `Unexpected error during PHP with XDebug image building!\n\n${e}`
346
+ )
347
+ }
348
+ }
349
+ }
350
+ ])
288
351
  },
289
352
  options: {
290
353
  bottomBar: 10
@@ -293,6 +356,5 @@ EOF`,
293
356
 
294
357
  module.exports = {
295
358
  buildProjectImage,
296
- buildDebugProjectImage,
297
359
  getEnabledExtensionsFromImage
298
360
  }
@@ -69,3 +69,69 @@ export function df(
69
69
  options?: SystemDFOptions<true>,
70
70
  execOptions?: ExecAsyncSpawnOptions<false>
71
71
  ): Promise<SystemDFResult>
72
+
73
+ export interface SystemVersionOptions<T extends boolean = false> {
74
+ format?: string
75
+ formatToJSON?: T
76
+ verbose?: boolean
77
+ }
78
+
79
+ interface DockerServiceComponent {
80
+ Name: string;
81
+ Version: string;
82
+ Details: {
83
+ ApiVersion?: string;
84
+ Arch?: string;
85
+ BuildTime?: string;
86
+ Experimental?: string;
87
+ GitCommit?: string;
88
+ GoVersion?: string;
89
+ KernelVersion?: string;
90
+ MinAPIVersion?: string;
91
+ Os?: string;
92
+ };
93
+ }
94
+ interface DockerServerInfo {
95
+ Platform: {
96
+ Name: string;
97
+ };
98
+ Components: DockerServiceComponent[];
99
+ Version: string;
100
+ ApiVersion: string;
101
+ MinAPIVersion: string;
102
+ GitCommit: string;
103
+ GoVersion: string;
104
+ Os: string;
105
+ Arch: string;
106
+ KernelVersion: string;
107
+ BuildTime: string;
108
+ }
109
+
110
+ interface DockerClientInfo {
111
+ Platform: {
112
+ Name: string;
113
+ };
114
+ Version: string;
115
+ ApiVersion: string;
116
+ DefaultAPIVersion: string;
117
+ GitCommit: string;
118
+ GoVersion: string;
119
+ Os: string;
120
+ Arch: string;
121
+ BuildTime: string;
122
+ Context: string;
123
+ }
124
+
125
+ export interface SystemVersionResult {
126
+ Client: DockerClientInfo
127
+ Server: DockerServerInfo
128
+ }
129
+
130
+ export function version(
131
+ options?: SystemVersionOptions,
132
+ execOptions?: ExecAsyncSpawnOptions<false>
133
+ ): Promise<string>
134
+ export function version(
135
+ options?: SystemVersionOptions<true>,
136
+ execOptions?: ExecAsyncSpawnOptions<false>
137
+ ): Promise<SystemVersionResult>
@@ -27,6 +27,33 @@ const df = async (options, execOptions = {}) => {
27
27
  return execAsyncSpawn(`docker system df ${args}`, execOptions)
28
28
  }
29
29
 
30
+ /**
31
+ * @param {import('./system-api').SystemVersionOptions} options
32
+ * @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions} execOptions
33
+ */
34
+ const version = async (options, execOptions = {}) => {
35
+ const { format, formatToJSON } = options
36
+
37
+ const formatArg =
38
+ !formatToJSON && format
39
+ ? `--format=${format}`
40
+ : formatToJSON && "--format='{{json .}}'"
41
+
42
+ const args = [formatArg].filter(Boolean).join(' ')
43
+
44
+ if (formatToJSON) {
45
+ const result = await execAsyncSpawn(
46
+ `docker version ${args}`,
47
+ execOptions
48
+ )
49
+
50
+ return JSON.parse(result)
51
+ }
52
+
53
+ return execAsyncSpawn(`docker version ${args}`, execOptions)
54
+ }
55
+
30
56
  module.exports = {
31
- df
57
+ df,
58
+ version
32
59
  }
@@ -15,7 +15,7 @@ const KnownError = require('../errors/known-error')
15
15
 
16
16
  /**
17
17
  *
18
- * @param {{ containername: string, commands: string[] }} argv
18
+ * @param {{ containerName: string, commands: string[] }} argv
19
19
  * @returns
20
20
  */
21
21
  const executeTask = async (argv) => {
@@ -47,17 +47,17 @@ const executeTask = async (argv) => {
47
47
  const services = Object.keys(containers)
48
48
 
49
49
  if (
50
- services.includes(argv.containername) ||
51
- services.some((service) => service.includes(argv.containername))
50
+ services.includes(argv.containerName) ||
51
+ services.some((service) => service.includes(argv.containerName))
52
52
  ) {
53
- const containerResult = containers[argv.containername]
54
- ? containers[argv.containername]
53
+ const containerResult = containers[argv.containerName]
54
+ ? containers[argv.containerName]
55
55
  : Object.entries(containers).find(([key]) =>
56
- key.includes(argv.containername)
56
+ key.includes(argv.containerName)
57
57
  )
58
58
 
59
59
  if (!containerResult) {
60
- logger.error(`No container found "${argv.containername}"`)
60
+ logger.error(`No container found "${argv.containerName}"`)
61
61
  process.exit(1)
62
62
  }
63
63
 
@@ -95,14 +95,14 @@ const executeTask = async (argv) => {
95
95
 
96
96
  const result = await executeInContainer({
97
97
  containerName: container.name,
98
- commands: argv.commands,
98
+ command: argv.commands.join(' '),
99
99
  user: container.user
100
100
  })
101
101
 
102
102
  return result
103
103
  }
104
104
 
105
- if (container.name.endsWith('php')) {
105
+ if (container.name.includes('php')) {
106
106
  if (process.stdout.isTTY) {
107
107
  logger.logN(
108
108
  `Starting container ${logger.style.misc(
@@ -127,7 +127,7 @@ const executeTask = async (argv) => {
127
127
  throw new KnownError(`Container ${container.name} is not running!`)
128
128
  }
129
129
 
130
- logger.error(`No container found "${argv.containername}"`)
130
+ logger.error(`No container found "${argv.containerName}"`)
131
131
  process.exit(1)
132
132
  }
133
133
 
@@ -10,7 +10,7 @@ const createNginxConfig = () => ({
10
10
  task: async (ctx) => {
11
11
  const {
12
12
  ports,
13
- config: { overridenConfiguration, baseConfig },
13
+ config: { overridenConfiguration, baseConfig, docker },
14
14
  isDockerDesktop
15
15
  } = ctx
16
16
 
@@ -19,10 +19,26 @@ const createNginxConfig = () => ({
19
19
  storeDomains
20
20
  } = overridenConfiguration
21
21
 
22
- const hostMachine = !isDockerDesktop
23
- ? '127.0.0.1'
24
- : 'host.docker.internal'
25
- const hostPort = !isDockerDesktop ? ports.app : 80
22
+ const networkSettings = {
23
+ phpNetwork: '127.0.0.1',
24
+ phpWithXdebugNetwork: '127.0.0.1',
25
+ fpmPort: ports.fpm,
26
+ fpmXdebugPort: ports.fpmXdebug,
27
+ hostPort: ports.app
28
+ }
29
+
30
+ if (isDockerDesktop) {
31
+ const containers = docker.getContainers(ports)
32
+
33
+ networkSettings.phpNetwork = containers.php.name
34
+ networkSettings.phpWithXdebugNetwork = containers.phpWithXdebug.name
35
+
36
+ networkSettings.fpmPort = 9000
37
+ networkSettings.fpmXdebugPort = 9001
38
+
39
+ networkSettings.hostPort = 80
40
+ }
41
+
26
42
  const useStoreDomainMapping =
27
43
  storeDomains && Object.keys(storeDomains).length > 1
28
44
 
@@ -37,10 +53,8 @@ const createNginxConfig = () => ({
37
53
  template: nginx.configTemplate,
38
54
  overwrite: true,
39
55
  templateArgs: {
40
- ports,
56
+ ...networkSettings,
41
57
  mageRoot: baseConfig.containerMagentoDir,
42
- hostMachine,
43
- hostPort,
44
58
  config: overridenConfiguration,
45
59
  storeDomains,
46
60
  useStoreDomainMapping
@@ -10,7 +10,6 @@ const {
10
10
  */
11
11
  const createPhpDebugConfig = () => ({
12
12
  title: 'Setting PHP XDebug config',
13
- skip: (ctx) => !ctx.debug,
14
13
  task: async (ctx) => {
15
14
  const {
16
15
  config: { php, baseConfig },
@@ -19,7 +18,7 @@ const createPhpDebugConfig = () => ({
19
18
  } = ctx
20
19
  const containers = ctx.config.docker.getContainers(ctx.ports)
21
20
  const phpExtensions = await getEnabledExtensionsFromImage(
22
- containers.php.debugImage
21
+ containers.phpWithXdebug.image
23
22
  )
24
23
  const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2')
25
24
 
@@ -0,0 +1,33 @@
1
+ const UnknownError = require('../../errors/unknown-error')
2
+ const setConfigFile = require('../../util/set-config')
3
+
4
+ /**
5
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
6
+ */
7
+ const createPhpFpmDebugConfig = () => ({
8
+ title: 'Setting php-fpm debug config',
9
+ task: async (ctx) => {
10
+ const {
11
+ config: { php },
12
+ isDockerDesktop
13
+ } = ctx
14
+ const port = !isDockerDesktop ? ctx.ports.fpmXdebug : 9000
15
+
16
+ try {
17
+ await setConfigFile({
18
+ configPathname: php.debugFpmConfPath,
19
+ template: php.fpmTemplatePath,
20
+ overwrite: true,
21
+ templateArgs: {
22
+ port
23
+ }
24
+ })
25
+ } catch (e) {
26
+ throw new UnknownError(
27
+ `Unexpected error accrued during php-fpm config creation\n\n${e}`
28
+ )
29
+ }
30
+ }
31
+ })
32
+
33
+ module.exports = createPhpFpmDebugConfig
@@ -3,7 +3,7 @@ const { nameKey, propertyKey } = require('../keys')
3
3
  const PHP_INTERPRETERS_COMPONENT_NAME = 'PhpInterpreters'
4
4
 
5
5
  /**
6
- * @param {Array} phpConfigs
6
+ * @param {Array<Record<string, any>>} phpConfigs
7
7
  * @param {import('../../../../../typings/context').ListrContext} ctx
8
8
  * @returns {Promise<Boolean>}
9
9
  */
@@ -13,8 +13,9 @@ const setupPHPInterpreters = async (phpConfigs, ctx) => {
13
13
  (phpConfig) => phpConfig[nameKey] === PHP_INTERPRETERS_COMPONENT_NAME
14
14
  )
15
15
 
16
- const { php } = ctx.config.docker.getContainers(ctx.ports)
17
- const currentInterpreterImage = ctx.debug ? php.debugImage : php.image
16
+ const {
17
+ phpWithXdebug: { image: currentInterpreterImage }
18
+ } = ctx.config.docker.getContainers(ctx.ports)
18
19
 
19
20
  const defaultPhpInterpreterConfiguration = {
20
21
  [nameKey]: currentInterpreterImage,
@@ -49,8 +50,7 @@ const setupPHPInterpreters = async (phpConfigs, ctx) => {
49
50
  const phpInterpreterConfiguration =
50
51
  phpInterpretersComponent.interpreters.interpreter.find(
51
52
  (interpreter) =>
52
- interpreter[nameKey] === php.image ||
53
- interpreter[nameKey] === php.debugImage
53
+ interpreter[nameKey] === currentInterpreterImage
54
54
  )
55
55
 
56
56
  if (!phpInterpreterConfiguration) {
@@ -18,7 +18,7 @@ const defaultComposerSettingsProperties = {
18
18
  }
19
19
 
20
20
  /**
21
- * @param {Array} workspaceConfigs
21
+ * @param {Array<Record<string, any>>} workspaceConfigs
22
22
  * @param {import('../../../../../typings/context').ListrContext} ctx
23
23
  * @returns {Promise<Boolean>}
24
24
  */
@@ -32,7 +32,7 @@ const setupComposerSettings = async (workspaceConfigs, ctx) => {
32
32
  const isComposerJsonExists = await pathExists(composerJsonPath)
33
33
  const { php } = ctx.config.docker.getContainers(ctx.ports)
34
34
  const defaultInterpreterConfig = {
35
- [nameKey]: ctx.debug ? php.debugImage : php.image,
35
+ [nameKey]: php.image,
36
36
  [composerKey]: 'composer'
37
37
  }
38
38
 
@@ -6,7 +6,7 @@ const PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME =
6
6
  const interpreterNameKey = '@_interpreter_name'
7
7
 
8
8
  /**
9
- * @param {Array} workspaceConfigs
9
+ * @param {Array<Record<string, any>>} workspaceConfigs
10
10
  * @param {import('../../../../../typings/context').ListrContext} ctx
11
11
  * @returns {Promise<Boolean>}
12
12
  */
@@ -17,8 +17,9 @@ const setupPHPWorkspaceProjectConfiguration = async (workspaceConfigs, ctx) => {
17
17
  workspaceConfig[nameKey] ===
18
18
  PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME
19
19
  )
20
- const { php } = ctx.config.docker.getContainers(ctx.ports)
21
- const currentInterpreterImage = ctx.debug ? php.debugImage : php.image
20
+ const {
21
+ php: { image: currentInterpreterImage }
22
+ } = ctx.config.docker.getContainers(ctx.ports)
22
23
 
23
24
  if (phpWorkspaceProjectConfigurationComponent) {
24
25
  if (