@scandipwa/magento-scripts 2.4.0-alpha.1 → 2.4.0-alpha.3
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/import-db.js +36 -3
- package/lib/config/docker.js +164 -56
- package/lib/config/port-config.js +46 -10
- package/lib/config/services/elasticsearch/default-es-env.js +1 -1
- package/lib/config/services/mariadb/versions/mariadb-10.2.js +3 -1
- package/lib/config/services/mariadb/versions/mariadb-10.3.js +3 -1
- package/lib/config/services/mariadb/versions/mariadb-10.4.js +3 -1
- package/lib/config/services/mariadb/versions/mariadb-10.6.js +3 -1
- package/lib/config/services/mariadb/versions/mariadb-11.4.js +3 -1
- package/lib/config/services/mariadb/versions/mariadb-11.6.js +3 -1
- package/lib/config/services/opensearch/default-os-env.js +1 -1
- package/lib/config/services/php/extensions/xdebug.js +1 -0
- package/lib/config/templates/nginx.template.conf +2 -2
- package/lib/config/templates/php-fpm.template.conf +3 -4
- package/lib/config/templates/ssl-terminator.template.conf +1 -1
- package/lib/tasks/database/create-magento-database.js +2 -1
- package/lib/tasks/database/fix-db.js +2 -0
- package/lib/tasks/database/import-dump-to-database.js +7 -4
- package/lib/tasks/database/import-remote-db/ssh/index.js +1 -1
- package/lib/tasks/database/import-remote-db/ssh/readymage.js +1 -1
- package/lib/tasks/database/import-remote-db/ssh/regular-server.js +1 -1
- package/lib/tasks/docker/containers/container-api.d.ts +5 -0
- package/lib/tasks/docker/containers/container-api.js +3 -1
- package/lib/tasks/docker/containers/tasks.js +86 -21
- package/lib/tasks/docker/project-image-builder.js +57 -44
- package/lib/tasks/docker/system/system-api.d.ts +66 -0
- package/lib/tasks/docker/system/system-api.js +28 -1
- package/lib/tasks/execute.js +1 -1
- package/lib/tasks/file-system/create-nginx-config.js +22 -8
- package/lib/tasks/file-system/create-php-fpm-config.js +6 -1
- package/lib/tasks/file-system/create-php-fpm-debug-config.js +6 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +20 -7
- package/lib/tasks/magento/install-magento-project.js +101 -34
- package/lib/tasks/magento/setup-magento/check-file-permissions.php +55 -0
- package/lib/tasks/magento/setup-magento/disable-custom-admin-path.js +21 -0
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +13 -0
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/make-magento-binaries-executable.js +44 -0
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +8 -5
- package/lib/tasks/magento/setup-magento/set-mail-config.js +16 -2
- package/lib/tasks/magento/setup-magento/setup-file-permissions.js +236 -0
- package/lib/tasks/php/php-container.js +21 -6
- package/lib/tasks/php/update-env-php.js +3 -9
- package/lib/tasks/requirements/cgroup-version.js +69 -0
- package/lib/tasks/requirements/elasticsearch-version.js +19 -3
- package/lib/tasks/requirements/index.js +3 -0
- package/lib/tasks/requirements/opensearch-version.js +1 -1
- package/lib/tasks/requirements/searchengine-version.js +1 -2
- package/lib/tasks/status/index.js +1 -0
- package/lib/util/database.js +36 -0
- package/lib/util/dockerfile-builder/build-instructions.js +5 -1
- package/lib/util/dockerfile-builder/types.d.ts +1 -1
- package/lib/util/execute-in-container.js +3 -1
- package/lib/util/get-installed-magento-version.js +60 -2
- package/lib/util/portscanner.js +3 -3
- package/lib/util/run-composer.js +1 -1
- package/lib/util/run-magento.js +2 -1
- package/lib/util/run-php.js +2 -1
- package/lib/util/set-config.js +4 -2
- package/package.json +16 -16
- package/typings/context.d.ts +4 -2
- package/typings/index.d.ts +10 -0
|
@@ -39,14 +39,16 @@ const copyDatabaseDumpIntoContainer = () => ({
|
|
|
39
39
|
const runSetGlobalLogBinTrustFunctionCreatorsCommand = () => ({
|
|
40
40
|
task: async (ctx, task) => {
|
|
41
41
|
const {
|
|
42
|
-
config: { docker },
|
|
42
|
+
config: { docker, overridenConfiguration },
|
|
43
43
|
ports
|
|
44
44
|
} = ctx
|
|
45
45
|
const { mariadb } = docker.getContainers(ports)
|
|
46
46
|
|
|
47
|
+
const { binFileName } = overridenConfiguration.configuration.mariadb
|
|
48
|
+
|
|
47
49
|
return task.newListr(
|
|
48
50
|
execCommandTask(
|
|
49
|
-
`docker exec ${mariadb.name} bash -c '
|
|
51
|
+
`docker exec ${mariadb.name} bash -c '${binFileName} -uroot -p${mariadb.env.MARIADB_ROOT_PASSWORD} -e "SET GLOBAL log_bin_trust_function_creators = 1;"'`
|
|
50
52
|
)
|
|
51
53
|
)
|
|
52
54
|
}
|
|
@@ -95,10 +97,11 @@ Note that you will lose your existing database!`,
|
|
|
95
97
|
const executeImportDumpSQL = () => ({
|
|
96
98
|
task: async (ctx, task) => {
|
|
97
99
|
const {
|
|
98
|
-
config: { docker },
|
|
100
|
+
config: { docker, overridenConfiguration },
|
|
99
101
|
ports
|
|
100
102
|
} = ctx
|
|
101
103
|
const { mariadb } = docker.getContainers(ports)
|
|
104
|
+
const { binFileName } = overridenConfiguration.configuration.mariadb
|
|
102
105
|
|
|
103
106
|
const userCredentialsForMariaDBCLI = await task.prompt({
|
|
104
107
|
type: 'Select',
|
|
@@ -117,7 +120,7 @@ const executeImportDumpSQL = () => ({
|
|
|
117
120
|
]
|
|
118
121
|
})
|
|
119
122
|
|
|
120
|
-
const importCommand = `docker exec ${mariadb.name} bash -c "
|
|
123
|
+
const importCommand = `docker exec ${mariadb.name} bash -c "${binFileName} ${userCredentialsForMariaDBCLI} magento < ./dump.sql"`
|
|
121
124
|
|
|
122
125
|
const startImportTime = Date.now()
|
|
123
126
|
const tickInterval = setInterval(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const os = require('os')
|
|
2
|
-
const { NodeSSH } = require('node-ssh')
|
|
2
|
+
const { NodeSSH } = require('node-ssh-no-cpu-features')
|
|
3
3
|
const pathExists = require('../../../../util/path-exists')
|
|
4
4
|
const regularSSHServer = require('./regular-server')
|
|
5
5
|
const readymageSSH = require('./readymage')
|
|
@@ -4,7 +4,7 @@ const { execAsyncSpawn } = require('../../../../util/exec-async-command')
|
|
|
4
4
|
const databaseDumpCommandWithOptions = require('./database-dump-command')
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @returns {import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh').NodeSSH }>}
|
|
7
|
+
* @returns {import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh-no-cpu-features').NodeSSH }>}
|
|
8
8
|
*/
|
|
9
9
|
const readymageSSH = () => ({
|
|
10
10
|
task: async (ctx, task) => {
|
|
@@ -4,7 +4,7 @@ const { execAsyncSpawn } = require('../../../../util/exec-async-command')
|
|
|
4
4
|
const databaseDumpCommandWithOptions = require('./database-dump-command')
|
|
5
5
|
const KnownError = require('../../../../errors/known-error')
|
|
6
6
|
/**
|
|
7
|
-
* @returns {import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh').NodeSSH }>}
|
|
7
|
+
* @returns {import('listr2').ListrTask<import('../../../../../typings/context').ListrContext & { ssh: import('node-ssh-no-cpu-features').NodeSSH }>}
|
|
8
8
|
*/
|
|
9
9
|
const regularSSHServer = () => ({
|
|
10
10
|
task: async (ctx, task) => {
|
|
@@ -103,7 +103,7 @@ const run = (options, execOptions = {}) =>
|
|
|
103
103
|
* @param {import('./container-api').ContainerExecOptions} options
|
|
104
104
|
*/
|
|
105
105
|
const execCommand = (options) => {
|
|
106
|
-
const { command, container, env, tty, user, workdir } = options
|
|
106
|
+
const { command, container, env, tty, user, workdir, interactive } = options
|
|
107
107
|
const envArgs = !env
|
|
108
108
|
? ''
|
|
109
109
|
: Object.entries(env)
|
|
@@ -112,6 +112,7 @@ const execCommand = (options) => {
|
|
|
112
112
|
const ttyArg = tty ? '--tty' : ''
|
|
113
113
|
const userArg = user ? `--user=${user}` : ''
|
|
114
114
|
const workdirArg = workdir ? `--workdir=${workdir}` : ''
|
|
115
|
+
const interactiveArg = interactive ? '--interactive' : ''
|
|
115
116
|
|
|
116
117
|
const dockerCommand = [
|
|
117
118
|
'docker',
|
|
@@ -119,6 +120,7 @@ const execCommand = (options) => {
|
|
|
119
120
|
'exec',
|
|
120
121
|
envArgs,
|
|
121
122
|
ttyArg,
|
|
123
|
+
interactiveArg,
|
|
122
124
|
userArg,
|
|
123
125
|
workdirArg,
|
|
124
126
|
container,
|
|
@@ -148,40 +148,105 @@ const pullImages = () => ({
|
|
|
148
148
|
*/
|
|
149
149
|
const startContainers = () => ({
|
|
150
150
|
title: 'Starting containers',
|
|
151
|
-
task: async ({ ports, config: { docker }
|
|
151
|
+
task: async ({ ports, config: { docker } }, task) => {
|
|
152
152
|
const containerList = await containerApi.ls({
|
|
153
153
|
formatToJSON: true,
|
|
154
154
|
all: true
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
-
const missingContainers = Object.
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
const missingContainers = Object.entries(docker.getContainers(ports))
|
|
158
|
+
.filter(
|
|
159
|
+
([nameWithoutPrefix, { name }]) =>
|
|
160
|
+
!containerList.some((c) => c.Names === name)
|
|
161
|
+
)
|
|
162
|
+
.map(([nameWithoutPrefix, containerOptions]) => ({
|
|
163
|
+
...containerOptions,
|
|
164
|
+
nameWithoutPrefix
|
|
165
|
+
}))
|
|
160
166
|
|
|
161
167
|
if (missingContainers.length === 0) {
|
|
162
168
|
task.skip()
|
|
163
169
|
return
|
|
164
170
|
}
|
|
165
171
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
)
|
|
172
|
+
const containerStatuses = missingContainers.reduce(
|
|
173
|
+
(acc, container) => ({
|
|
174
|
+
...acc,
|
|
175
|
+
[container.nameWithoutPrefix]: {
|
|
176
|
+
started: false,
|
|
177
|
+
onStarted: []
|
|
178
|
+
}
|
|
179
|
+
}),
|
|
180
|
+
{}
|
|
181
|
+
)
|
|
174
182
|
|
|
175
|
-
|
|
176
|
-
|
|
183
|
+
return task.newListr(
|
|
184
|
+
missingContainers.map((container) => ({
|
|
185
|
+
title: `Deploying ${logger.style.file(container._)} container`,
|
|
186
|
+
task: async (subCtx, subTask) => {
|
|
187
|
+
const { dependsOn } = container
|
|
188
|
+
if (Array.isArray(dependsOn)) {
|
|
189
|
+
const startedContainers = []
|
|
190
|
+
subTask.title = `Container ${
|
|
191
|
+
container._
|
|
192
|
+
} is waiting for ${dependsOn.join(', ')} to start...`
|
|
193
|
+
await Promise.all(
|
|
194
|
+
dependsOn.map(
|
|
195
|
+
async (name) =>
|
|
196
|
+
new Promise((resolve, reject) => {
|
|
197
|
+
const timeout = setTimeout(
|
|
198
|
+
() => {
|
|
199
|
+
reject(
|
|
200
|
+
new Error(
|
|
201
|
+
`Container ${name} not started in time`
|
|
202
|
+
)
|
|
203
|
+
)
|
|
204
|
+
},
|
|
205
|
+
// 2 minutes
|
|
206
|
+
1000 * 60 * 2
|
|
207
|
+
)
|
|
208
|
+
containerStatuses[name].onStarted.push(
|
|
209
|
+
() => {
|
|
210
|
+
startedContainers.push(name)
|
|
211
|
+
subTask.title = `Container ${
|
|
212
|
+
container._
|
|
213
|
+
} is waiting for ${dependsOn
|
|
214
|
+
.filter(
|
|
215
|
+
(d) =>
|
|
216
|
+
!startedContainers.includes(
|
|
217
|
+
d
|
|
218
|
+
)
|
|
219
|
+
)
|
|
220
|
+
.join(', ')} to start...`
|
|
221
|
+
clearTimeout(timeout)
|
|
222
|
+
resolve()
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
})
|
|
226
|
+
)
|
|
227
|
+
)
|
|
228
|
+
}
|
|
177
229
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
230
|
+
subTask.title = `${container._} is starting...`
|
|
231
|
+
|
|
232
|
+
await containerApi.run(container)
|
|
233
|
+
|
|
234
|
+
containerStatuses[
|
|
235
|
+
container.nameWithoutPrefix
|
|
236
|
+
].started = true
|
|
237
|
+
containerStatuses[
|
|
238
|
+
container.nameWithoutPrefix
|
|
239
|
+
].onStarted.forEach((cb) => {
|
|
240
|
+
cb()
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
subTask.output = `${container._} container started`
|
|
244
|
+
}
|
|
245
|
+
})),
|
|
246
|
+
{
|
|
247
|
+
concurrent: true,
|
|
248
|
+
exitOnError: true
|
|
249
|
+
}
|
|
185
250
|
)
|
|
186
251
|
},
|
|
187
252
|
options: {
|
|
@@ -169,9 +169,11 @@ const buildDockerFileInstructions = async (
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
if (
|
|
172
|
+
if (ctx.platform === 'linux') {
|
|
173
|
+
const { gid, username } = os.userInfo()
|
|
173
174
|
dockerFileInstructions.run(
|
|
174
|
-
`
|
|
175
|
+
`addgroup -g ${gid} ${username} && adduser -u ${gid} -G ${username} -H -s /sbin/nologin -D ${username} && \
|
|
176
|
+
addgroup www-data ${username}`
|
|
175
177
|
)
|
|
176
178
|
}
|
|
177
179
|
|
|
@@ -286,58 +288,69 @@ const buildProjectImage = () => ({
|
|
|
286
288
|
title: 'Building Project Images',
|
|
287
289
|
task: async (ctx, task) => {
|
|
288
290
|
const containers = ctx.config.docker.getContainers(ctx.ports)
|
|
289
|
-
const [image, tag = 'latest'] =
|
|
290
|
-
ctx.config.overridenConfiguration.configuration.php.baseImage.split(
|
|
291
|
-
':'
|
|
292
|
-
)
|
|
293
|
-
const dockerFileInstructions = await buildDockerFileInstructions(ctx, {
|
|
294
|
-
image,
|
|
295
|
-
tag,
|
|
296
|
-
ignorePHPExtensions: ['xdebug']
|
|
297
|
-
})
|
|
298
291
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
292
|
+
return task.newListr([
|
|
293
|
+
{
|
|
294
|
+
title: 'Building PHP image',
|
|
295
|
+
task: async () => {
|
|
296
|
+
const [image, tag = 'latest'] =
|
|
297
|
+
ctx.config.overridenConfiguration.configuration.php.baseImage.split(
|
|
298
|
+
':'
|
|
299
|
+
)
|
|
300
|
+
const dockerFileInstructions =
|
|
301
|
+
await buildDockerFileInstructions(ctx, {
|
|
302
|
+
image,
|
|
303
|
+
tag,
|
|
304
|
+
ignorePHPExtensions: ['xdebug']
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
await execAsyncSpawn(
|
|
309
|
+
`docker build -t ${containers.php.image} -<<EOF
|
|
302
310
|
${dockerFileInstructions}
|
|
303
311
|
EOF`,
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
312
|
+
{
|
|
313
|
+
callback: (r) => {
|
|
314
|
+
task.output = r
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
} catch (e) {
|
|
319
|
+
throw new KnownError(
|
|
320
|
+
`Unexpected error during PHP image building!\n\n${e}`
|
|
321
|
+
)
|
|
307
322
|
}
|
|
308
323
|
}
|
|
309
|
-
|
|
310
|
-
} catch (e) {
|
|
311
|
-
throw new KnownError(
|
|
312
|
-
`Unexpected error during project image building!\n\n${e}`
|
|
313
|
-
)
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const [phpImage, phpTag] = containers.php.image.split(':')
|
|
317
|
-
const debugImageInstructions = await buildDebugDockerFileInstructions(
|
|
318
|
-
ctx,
|
|
324
|
+
},
|
|
319
325
|
{
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
title: 'Building PHP with XDebug image',
|
|
327
|
+
task: async () => {
|
|
328
|
+
const [phpImage, phpTag] = containers.php.image.split(':')
|
|
329
|
+
const debugImageInstructions =
|
|
330
|
+
await buildDebugDockerFileInstructions(ctx, {
|
|
331
|
+
image: phpImage,
|
|
332
|
+
tag: phpTag
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
try {
|
|
336
|
+
await execAsyncSpawn(
|
|
337
|
+
`docker build -t ${containers.phpWithXdebug.image} -<<EOF
|
|
328
338
|
${debugImageInstructions}
|
|
329
339
|
EOF`,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
340
|
+
{
|
|
341
|
+
callback: (r) => {
|
|
342
|
+
task.output = r
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
} catch (e) {
|
|
347
|
+
throw new KnownError(
|
|
348
|
+
`Unexpected error during PHP with XDebug image building!\n\n${e}`
|
|
349
|
+
)
|
|
333
350
|
}
|
|
334
351
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
throw new KnownError(
|
|
338
|
-
`Unexpected error during project image building!\n\n${e}`
|
|
339
|
-
)
|
|
340
|
-
}
|
|
352
|
+
}
|
|
353
|
+
])
|
|
341
354
|
},
|
|
342
355
|
options: {
|
|
343
356
|
bottomBar: 10
|
|
@@ -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
|
}
|
package/lib/tasks/execute.js
CHANGED
|
@@ -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
|
|
23
|
-
|
|
24
|
-
: '
|
|
25
|
-
|
|
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
|
-
|
|
56
|
+
...networkSettings,
|
|
41
57
|
mageRoot: baseConfig.containerMagentoDir,
|
|
42
|
-
hostMachine,
|
|
43
|
-
hostPort,
|
|
44
58
|
config: overridenConfiguration,
|
|
45
59
|
storeDomains,
|
|
46
60
|
useStoreDomainMapping
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const os = require('os')
|
|
1
2
|
const UnknownError = require('../../errors/unknown-error')
|
|
2
3
|
const setConfigFile = require('../../util/set-config')
|
|
3
4
|
|
|
@@ -13,13 +14,17 @@ const createPhpFpmConfig = () => ({
|
|
|
13
14
|
} = ctx
|
|
14
15
|
const port = !isDockerDesktop ? ctx.ports.fpm : 9000
|
|
15
16
|
|
|
17
|
+
const user =
|
|
18
|
+
ctx.platform === 'linux' ? os.userInfo().username : 'www-data'
|
|
19
|
+
|
|
16
20
|
try {
|
|
17
21
|
await setConfigFile({
|
|
18
22
|
configPathname: php.fpmConfPath,
|
|
19
23
|
template: php.fpmTemplatePath,
|
|
20
24
|
overwrite: true,
|
|
21
25
|
templateArgs: {
|
|
22
|
-
port
|
|
26
|
+
port,
|
|
27
|
+
user
|
|
23
28
|
}
|
|
24
29
|
})
|
|
25
30
|
} catch (e) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const os = require('os')
|
|
1
2
|
const UnknownError = require('../../errors/unknown-error')
|
|
2
3
|
const setConfigFile = require('../../util/set-config')
|
|
3
4
|
|
|
@@ -13,13 +14,17 @@ const createPhpFpmDebugConfig = () => ({
|
|
|
13
14
|
} = ctx
|
|
14
15
|
const port = !isDockerDesktop ? ctx.ports.fpmXdebug : 9000
|
|
15
16
|
|
|
17
|
+
const user =
|
|
18
|
+
ctx.platform === 'linux' ? os.userInfo().username : 'www-data'
|
|
19
|
+
|
|
16
20
|
try {
|
|
17
21
|
await setConfigFile({
|
|
18
22
|
configPathname: php.debugFpmConfPath,
|
|
19
23
|
template: php.fpmTemplatePath,
|
|
20
24
|
overwrite: true,
|
|
21
25
|
templateArgs: {
|
|
22
|
-
port
|
|
26
|
+
port,
|
|
27
|
+
user
|
|
23
28
|
}
|
|
24
29
|
})
|
|
25
30
|
} catch (e) {
|
|
@@ -15,8 +15,7 @@ const createSSLTerminatorConfig = () => ({
|
|
|
15
15
|
task: async (ctx) => {
|
|
16
16
|
const {
|
|
17
17
|
ports,
|
|
18
|
-
config: { overridenConfiguration, baseConfig },
|
|
19
|
-
debug,
|
|
18
|
+
config: { overridenConfiguration, baseConfig, docker },
|
|
20
19
|
isDockerDesktop
|
|
21
20
|
} = ctx
|
|
22
21
|
|
|
@@ -72,9 +71,24 @@ const createSSLTerminatorConfig = () => ({
|
|
|
72
71
|
)
|
|
73
72
|
}
|
|
74
73
|
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
:
|
|
74
|
+
const networkSettings = {
|
|
75
|
+
backendNetwork: '127.0.0.1',
|
|
76
|
+
backendPort: overridenConfiguration.configuration.varnish.enabled
|
|
77
|
+
? ports.varnish
|
|
78
|
+
: ports.app
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (isDockerDesktop) {
|
|
82
|
+
const containers = docker.getContainers(ports)
|
|
83
|
+
|
|
84
|
+
if (overridenConfiguration.configuration.varnish.enabled) {
|
|
85
|
+
networkSettings.backendNetwork = containers.varnish.name
|
|
86
|
+
networkSettings.backendPort = 80
|
|
87
|
+
} else {
|
|
88
|
+
networkSettings.backendNetwork = containers.nginx.name
|
|
89
|
+
networkSettings.backendPort = 80
|
|
90
|
+
}
|
|
91
|
+
}
|
|
78
92
|
const hostPort = !isDockerDesktop ? ports.sslTerminator : 80
|
|
79
93
|
|
|
80
94
|
const nginxVersionOutput = await run({
|
|
@@ -112,10 +126,9 @@ const createSSLTerminatorConfig = () => ({
|
|
|
112
126
|
overwrite: true,
|
|
113
127
|
templateArgs: {
|
|
114
128
|
ports,
|
|
115
|
-
|
|
129
|
+
...networkSettings,
|
|
116
130
|
hostPort,
|
|
117
131
|
config: overridenConfiguration,
|
|
118
|
-
debug,
|
|
119
132
|
isSSLDirectiveDeprecated
|
|
120
133
|
}
|
|
121
134
|
})
|