@scandipwa/magento-scripts 2.0.0-alpha.1 → 2.0.0-alpha.10
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/exec.js +71 -0
- package/index.js +1 -1
- package/lib/commands/execute.js +2 -57
- package/lib/config/docker.js +8 -5
- package/lib/config/services/elasticsearch/default-es-env.js +6 -0
- package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +2 -6
- package/lib/config/templates/magentorc.template +5 -5
- package/lib/config/templates/ssl-terminator.template.conf +8 -3
- package/lib/config/versions/magento-2.3.7-p4.js +44 -0
- package/lib/config/versions/magento-2.4.3-p3.js +46 -0
- package/lib/config/versions/magento-2.4.4-p1.js +46 -0
- package/lib/config/versions/magento-2.4.5.js +46 -0
- package/lib/tasks/docker/containers/container-api.d.ts +4 -0
- package/lib/tasks/docker/containers/container-api.js +26 -16
- package/lib/tasks/docker/project-image-builder.js +2 -2
- package/lib/tasks/execute.js +97 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +3 -2
- package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +3 -1
- package/lib/tasks/php/php-container.js +6 -2
- package/lib/tasks/requirements/docker/index.js +3 -1
- package/lib/tasks/start.js +1 -1
- package/lib/util/execute-in-container.js +63 -0
- package/package.json +4 -3
- package/lib/tasks/execute/index.js +0 -26
- 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') }
|
|
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);
|
package/lib/commands/execute.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
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
|
};
|
package/lib/config/docker.js
CHANGED
|
@@ -5,6 +5,7 @@ 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');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
@@ -137,7 +138,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
137
138
|
`${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
|
|
138
139
|
],
|
|
139
140
|
env: {
|
|
140
|
-
COMPOSER_AUTH: process.env.COMPOSER_AUTH || '',
|
|
141
|
+
COMPOSER_AUTH: JSON.stringify(JSON.parse(process.env.COMPOSER_AUTH), null, 0) || '',
|
|
141
142
|
COMPOSER_HOME: '/composer/home'
|
|
142
143
|
},
|
|
143
144
|
restart: 'on-failure:5',
|
|
@@ -259,10 +260,12 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
259
260
|
ports: [`127.0.0.1:${ ports.elasticsearch }:9200`],
|
|
260
261
|
forwardedPorts: [`127.0.0.1:${ ports.elasticsearch }:9200`],
|
|
261
262
|
mounts: [`source=${ volumes.elasticsearch.name },target=/usr/share/elasticsearch/data`],
|
|
262
|
-
env: deepmerge(
|
|
263
|
+
env: deepmerge(
|
|
264
|
+
{
|
|
263
265
|
// https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
|
|
264
|
-
|
|
265
|
-
|
|
266
|
+
'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
|
|
267
|
+
}, elasticsearch.env || defaultEsEnv
|
|
268
|
+
),
|
|
266
269
|
network: network.name,
|
|
267
270
|
image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
|
|
268
271
|
name: `${ prefix }_elasticsearch`
|
|
@@ -270,7 +273,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
270
273
|
};
|
|
271
274
|
|
|
272
275
|
if (ssl.enabled) {
|
|
273
|
-
dockerConfig.
|
|
276
|
+
dockerConfig.sslTerminator.ports.push(
|
|
274
277
|
`${isIpAddress(host) ? host : '127.0.0.1'}:443:443`
|
|
275
278
|
);
|
|
276
279
|
}
|
|
@@ -2,6 +2,7 @@ const os = require('os');
|
|
|
2
2
|
const { getArchSync } = require('../../../../util/arch');
|
|
3
3
|
const { deepmerge } = require('../../../../util/deepmerge');
|
|
4
4
|
const { repo } = require('../base-repo');
|
|
5
|
+
const defaultEnv = require('../default-es-env');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @returns {import('../../../../../typings/index').ServiceWithImage}
|
|
@@ -10,12 +11,7 @@ const elasticsearch68 = ({
|
|
|
10
11
|
image = `${ repo }:elasticsearch-6.8`
|
|
11
12
|
} = {}) => ({
|
|
12
13
|
image,
|
|
13
|
-
env: deepmerge({
|
|
14
|
-
'bootstrap.memory_lock': true,
|
|
15
|
-
'xpack.security.enabled': false,
|
|
16
|
-
'discovery.type': 'single-node',
|
|
17
|
-
ES_JAVA_OPTS: '-Xms512m -Xmx512m'
|
|
18
|
-
}, os.platform() === 'darwin' && getArchSync() === 'arm64' ? {
|
|
14
|
+
env: deepmerge(defaultEnv, os.platform() === 'darwin' && getArchSync() === 'arm64' ? {
|
|
19
15
|
'xpack.ml.enabled': false
|
|
20
16
|
} : {})
|
|
21
17
|
});
|
|
@@ -2,16 +2,16 @@ RED='\033[0;31m'
|
|
|
2
2
|
GREEN='\033[0;32m'
|
|
3
3
|
NC='\033[0m' # No Color
|
|
4
4
|
|
|
5
|
-
alias php="
|
|
5
|
+
alias php="node ./node_modules/.bin/magento-scripts-exec php php"
|
|
6
6
|
alias magento="php bin/magento"
|
|
7
7
|
alias magneto="echo -e 'Not ${RED}magneto${NC} but ${GREEN}magento${NC} please! or at least ${GREEN}m${NC}!' && magento"
|
|
8
8
|
alias m="magento"
|
|
9
|
-
alias composer="
|
|
9
|
+
alias composer="node ./node_modules/.bin/magento-scripts-exec php composer"
|
|
10
10
|
alias c="composer"
|
|
11
11
|
<% if (it.varnishEnabled) { %>
|
|
12
|
-
alias cvc="
|
|
12
|
+
alias cvc="node ./node_modules/.bin/magento-scripts-exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
|
|
13
13
|
<% } %>
|
|
14
|
-
alias mariadb="
|
|
15
|
-
alias mariadbroot="
|
|
14
|
+
alias mariadb="node ./node_modules/.bin/magento-scripts-exec mariadb 'mysql -umagento -pmagento'"
|
|
15
|
+
alias mariadbroot="node ./node_modules/.bin/magento-scripts-exec mariadb 'mysql -uroot -pscandipwa'"
|
|
16
16
|
|
|
17
17
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
|
@@ -12,20 +12,25 @@ upstream app_backend {
|
|
|
12
12
|
server {
|
|
13
13
|
listen <%= it.hostPort %>;
|
|
14
14
|
<% if (it.config.ssl.enabled) { %> listen 443 ssl;
|
|
15
|
-
server_name <%= it.networkToBindTo %>;
|
|
16
15
|
|
|
16
|
+
ssl on;
|
|
17
17
|
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
18
18
|
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
19
19
|
ssl_protocols TLSv1.2;<% } %>
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
<% if (it.config.host) { %>
|
|
22
|
+
server_name <%= it.config.host %><% if (it.config.ssl.enabled) { %> <%= it.networkToBindTo %><% } %>;
|
|
23
|
+
<% } else { %>
|
|
24
|
+
server_name <% if (it.config.ssl.enabled) { %> <%= it.networkToBindTo %><% } else { %>_<% } %>;
|
|
25
|
+
<% } %>
|
|
22
26
|
|
|
23
27
|
location / {
|
|
24
28
|
proxy_buffer_size 128k;
|
|
25
29
|
proxy_buffers 4 256k;
|
|
26
30
|
proxy_busy_buffers_size 256k;
|
|
27
31
|
proxy_set_header X-Real-IP $remote_addr;
|
|
28
|
-
proxy_set_header X-Forwarded-For $
|
|
32
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
33
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
29
34
|
proxy_set_header Host $http_host;
|
|
30
35
|
proxy_http_version 1.1;
|
|
31
36
|
proxy_set_header Connection "";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { magento23PHPExtensionList } = require('../magento/required-php-extensions');
|
|
4
|
+
const { repo } = require('../php/base-repo');
|
|
5
|
+
const { php74 } = require('../php/versions');
|
|
6
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
7
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
8
|
+
|
|
9
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
10
|
+
magentoVersion: '2.3.7-p4',
|
|
11
|
+
configuration: {
|
|
12
|
+
php: php74({
|
|
13
|
+
templateDir,
|
|
14
|
+
extensions: magento23PHPExtensionList,
|
|
15
|
+
baseImage: `${ repo }:php-7.4-magento-2.3`
|
|
16
|
+
}),
|
|
17
|
+
nginx: {
|
|
18
|
+
version: '1.18.0',
|
|
19
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
20
|
+
},
|
|
21
|
+
redis: {
|
|
22
|
+
version: '6'
|
|
23
|
+
},
|
|
24
|
+
mysql: {
|
|
25
|
+
version: '5.7'
|
|
26
|
+
},
|
|
27
|
+
mariadb: {
|
|
28
|
+
version: '10.2'
|
|
29
|
+
},
|
|
30
|
+
elasticsearch: {
|
|
31
|
+
version: '7.9.3'
|
|
32
|
+
},
|
|
33
|
+
composer: {
|
|
34
|
+
version: '2'
|
|
35
|
+
},
|
|
36
|
+
varnish: varnish66({ templateDir }),
|
|
37
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
38
|
+
},
|
|
39
|
+
magento: defaultMagentoConfig,
|
|
40
|
+
host: 'localhost',
|
|
41
|
+
ssl: {
|
|
42
|
+
enabled: false
|
|
43
|
+
}
|
|
44
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const sodium = require('../php/extensions/sodium');
|
|
4
|
+
const { magento24PHPExtensionList } = require('../magento/required-php-extensions');
|
|
5
|
+
const { php74 } = require('../php/versions');
|
|
6
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
7
|
+
const { varnish66 } = require('../varnish/varnish-6-6');
|
|
8
|
+
const { repo } = require('../php/base-repo');
|
|
9
|
+
|
|
10
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
11
|
+
magentoVersion: '2.4.3-p3',
|
|
12
|
+
isDefault: true,
|
|
13
|
+
configuration: {
|
|
14
|
+
php: php74({
|
|
15
|
+
templateDir,
|
|
16
|
+
extensions: { ...magento24PHPExtensionList, sodium },
|
|
17
|
+
baseImage: `${ repo }:php-7.4-magento-2.4`
|
|
18
|
+
}),
|
|
19
|
+
nginx: {
|
|
20
|
+
version: '1.18.0',
|
|
21
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
22
|
+
},
|
|
23
|
+
redis: {
|
|
24
|
+
version: '6.0'
|
|
25
|
+
},
|
|
26
|
+
mysql: {
|
|
27
|
+
version: '8.0'
|
|
28
|
+
},
|
|
29
|
+
mariadb: {
|
|
30
|
+
version: '10.4'
|
|
31
|
+
},
|
|
32
|
+
elasticsearch: {
|
|
33
|
+
version: '7.16.3'
|
|
34
|
+
},
|
|
35
|
+
composer: {
|
|
36
|
+
version: '2'
|
|
37
|
+
},
|
|
38
|
+
varnish: varnish66({ templateDir }),
|
|
39
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
40
|
+
},
|
|
41
|
+
magento: defaultMagentoConfig,
|
|
42
|
+
host: 'localhost',
|
|
43
|
+
ssl: {
|
|
44
|
+
enabled: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const sodium = require('../php/extensions/sodium');
|
|
4
|
+
const { magento24PHPExtensionList } = require('../magento/required-php-extensions');
|
|
5
|
+
const { php81 } = require('../php/versions');
|
|
6
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
7
|
+
const { varnish70 } = require('../varnish/varnish-7-0');
|
|
8
|
+
const { repo } = require('../php/base-repo');
|
|
9
|
+
|
|
10
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
11
|
+
magentoVersion: '2.4.4-p1',
|
|
12
|
+
isDefault: true,
|
|
13
|
+
configuration: {
|
|
14
|
+
php: php81({
|
|
15
|
+
templateDir,
|
|
16
|
+
extensions: { ...magento24PHPExtensionList, sodium },
|
|
17
|
+
baseImage: `${ repo }:php-8.1-magento-2.4`
|
|
18
|
+
}),
|
|
19
|
+
nginx: {
|
|
20
|
+
version: '1.18.0',
|
|
21
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
22
|
+
},
|
|
23
|
+
redis: {
|
|
24
|
+
version: '6.0'
|
|
25
|
+
},
|
|
26
|
+
mysql: {
|
|
27
|
+
version: '8.0'
|
|
28
|
+
},
|
|
29
|
+
mariadb: {
|
|
30
|
+
version: '10.4'
|
|
31
|
+
},
|
|
32
|
+
elasticsearch: {
|
|
33
|
+
version: '7.16.3'
|
|
34
|
+
},
|
|
35
|
+
composer: {
|
|
36
|
+
version: '2'
|
|
37
|
+
},
|
|
38
|
+
varnish: varnish70({ templateDir }),
|
|
39
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
40
|
+
},
|
|
41
|
+
magento: defaultMagentoConfig,
|
|
42
|
+
host: 'localhost',
|
|
43
|
+
ssl: {
|
|
44
|
+
enabled: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const sodium = require('../php/extensions/sodium');
|
|
4
|
+
const { magento24PHPExtensionList } = require('../magento/required-php-extensions');
|
|
5
|
+
const { php81 } = require('../php/versions');
|
|
6
|
+
const { sslTerminator } = require('../ssl-terminator');
|
|
7
|
+
const { varnish70 } = require('../varnish/varnish-7-0');
|
|
8
|
+
const { repo } = require('../php/base-repo');
|
|
9
|
+
|
|
10
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
11
|
+
magentoVersion: '2.4.5',
|
|
12
|
+
isDefault: true,
|
|
13
|
+
configuration: {
|
|
14
|
+
php: php81({
|
|
15
|
+
templateDir,
|
|
16
|
+
extensions: { ...magento24PHPExtensionList, sodium },
|
|
17
|
+
baseImage: `${ repo }:php-8.1-magento-2.4`
|
|
18
|
+
}),
|
|
19
|
+
nginx: {
|
|
20
|
+
version: '1.18.0',
|
|
21
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
22
|
+
},
|
|
23
|
+
redis: {
|
|
24
|
+
version: '6.0'
|
|
25
|
+
},
|
|
26
|
+
mysql: {
|
|
27
|
+
version: '8.0'
|
|
28
|
+
},
|
|
29
|
+
mariadb: {
|
|
30
|
+
version: '10.4'
|
|
31
|
+
},
|
|
32
|
+
elasticsearch: {
|
|
33
|
+
version: '7.17.5'
|
|
34
|
+
},
|
|
35
|
+
composer: {
|
|
36
|
+
version: '2'
|
|
37
|
+
},
|
|
38
|
+
varnish: varnish70({ templateDir }),
|
|
39
|
+
sslTerminator: sslTerminator({ templateDir })
|
|
40
|
+
},
|
|
41
|
+
magento: defaultMagentoConfig,
|
|
42
|
+
host: 'localhost',
|
|
43
|
+
ssl: {
|
|
44
|
+
enabled: false
|
|
45
|
+
}
|
|
46
|
+
});
|
|
@@ -69,6 +69,8 @@ export interface ContainerRunOptions {
|
|
|
69
69
|
* Run container in background and print container ID
|
|
70
70
|
*/
|
|
71
71
|
detach?: boolean
|
|
72
|
+
|
|
73
|
+
tty?: boolean
|
|
72
74
|
/**
|
|
73
75
|
* Publish or expose port [docs](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)
|
|
74
76
|
*/
|
|
@@ -126,3 +128,5 @@ export interface ContainerRunOptions {
|
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
export function run(containerOptions: ContainerRunOptions, execOptions?: ExecAsyncSpawnOptions<false>): Promise<false>
|
|
131
|
+
|
|
132
|
+
export function runCommand(options: ContainerRunOptions): string[]
|
|
@@ -3,9 +3,9 @@ const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @param {import('./container-api').ContainerRunOptions} options
|
|
6
|
-
* @
|
|
6
|
+
* @returns {string[]}
|
|
7
7
|
*/
|
|
8
|
-
const
|
|
8
|
+
const runCommand = (options) => {
|
|
9
9
|
const {
|
|
10
10
|
addHost,
|
|
11
11
|
ports = [],
|
|
@@ -24,32 +24,35 @@ const run = (options, execOptions = {}) => {
|
|
|
24
24
|
expose = [],
|
|
25
25
|
detach = true,
|
|
26
26
|
rm = false,
|
|
27
|
+
tty = false,
|
|
27
28
|
user
|
|
28
29
|
} = options;
|
|
29
30
|
|
|
30
31
|
const detachArg = detach && '-d';
|
|
31
32
|
const rmArg = rm && '--rm';
|
|
33
|
+
const ttyArg = tty && '-it';
|
|
32
34
|
const exposeArg = expose && expose.map((e) => `--expose=${ e }`);
|
|
33
|
-
const restartArg = !rm && restart && `--restart
|
|
34
|
-
const networkArg = network && `--network
|
|
35
|
-
const portsArgs = ports.map((port) => `-p
|
|
36
|
-
const mountsArgs = mounts.map((mount) => `--mount
|
|
37
|
-
const mountVolumesArgs = mountVolumes.map((mount) => `-v
|
|
38
|
-
const envArgs = !env ? '' : Object.entries(env).map(([key, value]) => `--env
|
|
39
|
-
const nameArg = name && `--name
|
|
40
|
-
const entrypointArg = entrypoint && `--entrypoint
|
|
41
|
-
const healthCheckArg = healthCheck && Object.entries(healthCheck).map(([key, value]) => `--health-${key}
|
|
42
|
-
const securityArg = securityOptions.length > 0 && securityOptions.map((opt) => `--security-opt
|
|
43
|
-
const tmpfsArg = tmpfs.length > 0 && tmpfs.map((t) => `--tmpfs
|
|
35
|
+
const restartArg = !rm && restart && `--restart=${ restart }`;
|
|
36
|
+
const networkArg = network && `--network=${ network }`;
|
|
37
|
+
const portsArgs = ports && ports.length > 0 && ports.map((port) => `-p=${ port }`).join(' ');
|
|
38
|
+
const mountsArgs = mounts && mounts.map((mount) => `--mount=${ mount }`).join(' ');
|
|
39
|
+
const mountVolumesArgs = mountVolumes && mountVolumes.map((mount) => `-v=${mount}`).join(' ');
|
|
40
|
+
const envArgs = !env ? '' : Object.entries(env).map(([key, value]) => `--env=${ key }='${ value }'`).join(' ');
|
|
41
|
+
const nameArg = name && `--name=${name}`;
|
|
42
|
+
const entrypointArg = entrypoint && `--entrypoint="${entrypoint}"`;
|
|
43
|
+
const healthCheckArg = healthCheck && Object.entries(healthCheck).map(([key, value]) => `--health-${key}='${value}'`).join(' ');
|
|
44
|
+
const securityArg = securityOptions.length > 0 && securityOptions.map((opt) => `--security-opt=${opt}`).join(' ');
|
|
45
|
+
const tmpfsArg = tmpfs.length > 0 && tmpfs.map((t) => `--tmpfs=${t}`).join(' ');
|
|
44
46
|
const userArg = user && `--user=${user}`;
|
|
45
47
|
const addHostArg = addHost && `--add-host=${addHost}`;
|
|
46
48
|
|
|
47
49
|
const dockerCommand = [
|
|
48
50
|
'docker',
|
|
49
51
|
'run',
|
|
52
|
+
nameArg,
|
|
53
|
+
ttyArg,
|
|
50
54
|
detachArg,
|
|
51
55
|
rmArg,
|
|
52
|
-
nameArg,
|
|
53
56
|
networkArg,
|
|
54
57
|
restartArg,
|
|
55
58
|
portsArgs,
|
|
@@ -65,11 +68,17 @@ const run = (options, execOptions = {}) => {
|
|
|
65
68
|
addHostArg,
|
|
66
69
|
image,
|
|
67
70
|
command
|
|
68
|
-
].filter(Boolean).
|
|
71
|
+
].filter(Boolean).filter((arg) => typeof arg === 'string');
|
|
69
72
|
|
|
70
|
-
return
|
|
73
|
+
return dockerCommand;
|
|
71
74
|
};
|
|
72
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @param {import('./container-api').ContainerRunOptions} options
|
|
78
|
+
* @param {import('../../../util/exec-async-command').ExecAsyncSpawnOptions<false>} execOptions
|
|
79
|
+
*/
|
|
80
|
+
const run = (options, execOptions = {}) => execAsyncSpawn(runCommand(options).join(' '), execOptions);
|
|
81
|
+
|
|
73
82
|
/**
|
|
74
83
|
* @param {string} command
|
|
75
84
|
* @param {string} container container id or name
|
|
@@ -148,6 +157,7 @@ const ls = async (options = {}, execOptions = {}) => {
|
|
|
148
157
|
|
|
149
158
|
module.exports = {
|
|
150
159
|
run,
|
|
160
|
+
runCommand,
|
|
151
161
|
exec,
|
|
152
162
|
ls
|
|
153
163
|
};
|
|
@@ -68,9 +68,9 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
|
68
68
|
.comment('project image')
|
|
69
69
|
.from({ image, tag });
|
|
70
70
|
|
|
71
|
-
// install bash in image
|
|
71
|
+
// install bash and patch in image
|
|
72
72
|
dockerFileInstructions
|
|
73
|
-
.run('apk add --no-cache bash');
|
|
73
|
+
.run('apk add --no-cache bash patch');
|
|
74
74
|
|
|
75
75
|
if (missingExtensions.length > 0) {
|
|
76
76
|
const allDependencies = missingExtensions.map(
|