@scandipwa/magento-scripts 1.14.1-alpha.1 → 1.14.1-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/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/config/docker.js +85 -12
- package/lib/config/get-port-config.js +7 -2
- package/lib/config/port-config.js +3 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +250 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/tasks/cli/create-bashrc-config.js +5 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +7 -39
- package/lib/tasks/file-system/create-php-storm-config.js +82 -0
- package/lib/tasks/file-system/create-ssl-terminator-config.js +94 -0
- package/lib/tasks/file-system/create-varnish-config.js +74 -0
- package/lib/tasks/file-system/index.js +6 -2
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/php/index.js +1 -1
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- package/lib/tasks/requirements/docker/index.js +2 -0
- package/lib/tasks/requirements/docker/install.js +11 -11
- package/lib/tasks/requirements/docker/running-status.js +137 -0
- package/lib/tasks/requirements/docker/version.js +2 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/php-version.js +3 -1
- package/lib/tasks/start.js +3 -8
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +26 -8
- package/lib/tasks/theme/install-theme.js +16 -4
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/setup-persisted-query.js +3 -3
- package/lib/tasks/theme/setup-themes.js +3 -2
- package/lib/tasks/theme/symlink-theme.js +18 -3
- package/lib/util/config-file-validator.js +12 -1
- package/lib/util/config-php-json.js +19 -0
- package/lib/util/instance-metadata.js +2 -2
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +6 -2
- package/lib/util/run-php.js +7 -1
- package/lib/util/systemctl.js +46 -0
- package/package.json +2 -3
- package/typings/context.d.ts +5 -3
- package/typings/index.d.ts +32 -1
- package/lib/config/xml-parser.js +0 -61
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -83
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
- package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
- package/typings/phpstorm.d.ts +0 -33
package/index.js
CHANGED
|
@@ -5,6 +5,19 @@ const getLatestVersion = require('@scandipwa/scandipwa-dev-utils/latest-version'
|
|
|
5
5
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
6
6
|
const semver = require('semver');
|
|
7
7
|
const isInstalledGlobally = require('is-installed-globally');
|
|
8
|
+
const isRunningRoot = require('./lib/util/is-running-root');
|
|
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') }, ${ 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.
|
|
17
|
+
`);
|
|
18
|
+
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
8
21
|
|
|
9
22
|
const commands = [
|
|
10
23
|
require('./lib/commands/link'),
|
package/lib/commands/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ const getProjectConfiguration = require('../config/get-project-configuration');
|
|
|
7
7
|
const localAuthJson = require('../tasks/composer/local-auth-json');
|
|
8
8
|
const checkConfigurationFile = require('../config/check-configuration-file');
|
|
9
9
|
const { installComposer, installPrestissimo } = require('../tasks/composer');
|
|
10
|
+
const ConsoleBlock = require('../util/console-block');
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @param {import('yargs')} yargs
|
|
@@ -30,13 +31,39 @@ module.exports = (yargs) => {
|
|
|
30
31
|
rendererOptions: { collapse: false, clearOutput: true }
|
|
31
32
|
});
|
|
32
33
|
|
|
34
|
+
let ctx;
|
|
33
35
|
try {
|
|
34
|
-
await tasks.run();
|
|
36
|
+
ctx = await tasks.run();
|
|
35
37
|
} catch (e) {
|
|
36
38
|
logger.error(e.message || e);
|
|
37
39
|
process.exit(1);
|
|
38
40
|
}
|
|
39
41
|
|
|
42
|
+
const block = new ConsoleBlock();
|
|
43
|
+
|
|
44
|
+
block
|
|
45
|
+
.addHeader('Create Magento App CLI')
|
|
46
|
+
.addEmptyLine()
|
|
47
|
+
.addLine(`Available aliases: ${logger.style.command('php')}, ${logger.style.command('magento')}, ${logger.style.command('composer')}`)
|
|
48
|
+
.addLine(`Available shortcuts: magento -> ${logger.style.command('m')}, composer -> ${logger.style.command('c')}`)
|
|
49
|
+
.addEmptyLine();
|
|
50
|
+
|
|
51
|
+
if (ctx.config.overridenConfiguration.configuration.varnish.enabled) {
|
|
52
|
+
block.addLine(`Clear Varnish cache: ${logger.style.command('cvc')}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
block
|
|
56
|
+
.addLine(`Clear Magento cache: ${logger.style.command('m c:c')}`)
|
|
57
|
+
.addLine(`Magento setup upgrade: ${logger.style.command('m se:up')}`)
|
|
58
|
+
.addLine(`Magento DI compile: ${logger.style.command('m s:d:c')}`);
|
|
59
|
+
|
|
60
|
+
block
|
|
61
|
+
.addEmptyLine()
|
|
62
|
+
.addLine(`Clear Composer cache: ${logger.style.command('c cc')}`)
|
|
63
|
+
.addEmptyLine();
|
|
64
|
+
|
|
65
|
+
block.log();
|
|
66
|
+
|
|
40
67
|
return cli();
|
|
41
68
|
});
|
|
42
69
|
};
|
package/lib/commands/execute.js
CHANGED
package/lib/config/docker.js
CHANGED
|
@@ -12,7 +12,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
12
12
|
redis,
|
|
13
13
|
mysql,
|
|
14
14
|
elasticsearch,
|
|
15
|
-
mariadb
|
|
15
|
+
mariadb,
|
|
16
|
+
varnish
|
|
16
17
|
} = configuration;
|
|
17
18
|
|
|
18
19
|
const {
|
|
@@ -42,7 +43,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
42
43
|
const isLinux = os.platform() === 'linux';
|
|
43
44
|
const isWsl = await getIsWsl();
|
|
44
45
|
const isArm = (await getArch()) === 'arm64';
|
|
45
|
-
const
|
|
46
|
+
const isNotNativeLinux = (!isLinux || isWsl);
|
|
46
47
|
|
|
47
48
|
if (!isLinux) {
|
|
48
49
|
/**
|
|
@@ -53,7 +54,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
53
54
|
name: `${ prefix }_nginx-data`,
|
|
54
55
|
opts: {
|
|
55
56
|
type: 'nfs',
|
|
56
|
-
device:
|
|
57
|
+
device: path.join(cacheDir, 'nginx', 'conf.d'),
|
|
57
58
|
o: 'bind'
|
|
58
59
|
}
|
|
59
60
|
};
|
|
@@ -61,7 +62,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
61
62
|
name: `${ prefix }_pub-data`,
|
|
62
63
|
opts: {
|
|
63
64
|
type: 'nfs',
|
|
64
|
-
device:
|
|
65
|
+
device: path.join(magentoDir, 'pub'),
|
|
65
66
|
o: 'bind'
|
|
66
67
|
}
|
|
67
68
|
};
|
|
@@ -69,18 +70,62 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
69
70
|
name: `${ prefix }_setup-data`,
|
|
70
71
|
opts: {
|
|
71
72
|
type: 'nfs',
|
|
72
|
-
device:
|
|
73
|
+
device: path.join(magentoDir, 'setup'),
|
|
73
74
|
o: 'bind'
|
|
74
75
|
}
|
|
75
76
|
};
|
|
77
|
+
volumes.sslTerminator = {
|
|
78
|
+
name: `${ prefix }_ssl-terminator-data`,
|
|
79
|
+
opts: {
|
|
80
|
+
type: 'nfs',
|
|
81
|
+
device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
|
|
82
|
+
o: 'bind'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (varnish.enabled) {
|
|
87
|
+
volumes.varnish = {
|
|
88
|
+
name: `${ prefix }_varnish-data`,
|
|
89
|
+
opts: {
|
|
90
|
+
type: 'nfs',
|
|
91
|
+
device: path.join(cacheDir, 'varnish'),
|
|
92
|
+
o: 'bind'
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
76
96
|
}
|
|
77
97
|
|
|
78
98
|
const getContainers = (ports = {}) => {
|
|
79
99
|
const dockerConfig = {
|
|
100
|
+
sslTerminator: {
|
|
101
|
+
_: 'SSL Terminator (Nginx)',
|
|
102
|
+
ports: isNotNativeLinux ? [
|
|
103
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.sslTerminator }:80`
|
|
104
|
+
] : [],
|
|
105
|
+
healthCheck: {
|
|
106
|
+
cmd: 'service nginx status'
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Mount volumes directly on linux
|
|
110
|
+
*/
|
|
111
|
+
mountVolumes: [
|
|
112
|
+
`${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
|
|
113
|
+
],
|
|
114
|
+
restart: 'on-failure:5',
|
|
115
|
+
// TODO: use connect instead
|
|
116
|
+
network: isNotNativeLinux ? network.name : 'host',
|
|
117
|
+
image: `nginx:${ nginx.version }`,
|
|
118
|
+
imageDetails: {
|
|
119
|
+
name: 'nginx',
|
|
120
|
+
tag: nginx.version
|
|
121
|
+
},
|
|
122
|
+
name: `${ prefix }_ssl-terminator`,
|
|
123
|
+
command: "nginx -g 'daemon off;'"
|
|
124
|
+
},
|
|
80
125
|
nginx: {
|
|
81
126
|
_: 'Nginx',
|
|
82
|
-
ports:
|
|
83
|
-
`${isIpAddress(host) ? host : '127.0.0.1'}:${ ports.app }:80`
|
|
127
|
+
ports: isNotNativeLinux ? [
|
|
128
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.app }:80`
|
|
84
129
|
] : [],
|
|
85
130
|
healthCheck: {
|
|
86
131
|
cmd: 'service nginx status'
|
|
@@ -99,7 +144,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
99
144
|
],
|
|
100
145
|
restart: 'on-failure:5',
|
|
101
146
|
// TODO: use connect instead
|
|
102
|
-
network:
|
|
147
|
+
network: isNotNativeLinux ? network.name : 'host',
|
|
103
148
|
image: `nginx:${ nginx.version }`,
|
|
104
149
|
imageDetails: {
|
|
105
150
|
name: 'nginx',
|
|
@@ -126,7 +171,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
126
171
|
connectCommand: ['redis-cli']
|
|
127
172
|
},
|
|
128
173
|
mysql: {
|
|
129
|
-
_: !
|
|
174
|
+
_: !isArm ? 'MySQL' : 'MariaDB',
|
|
130
175
|
healthCheck: {
|
|
131
176
|
cmd: 'mysqladmin ping --silent'
|
|
132
177
|
},
|
|
@@ -154,15 +199,15 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
154
199
|
'seccomp=unconfined'
|
|
155
200
|
],
|
|
156
201
|
network: network.name,
|
|
157
|
-
image: !
|
|
158
|
-
imageDetails: !
|
|
202
|
+
image: !isArm ? `mysql:${ mysql.version }` : `mariadb:${ mariadb.version }`,
|
|
203
|
+
imageDetails: !isArm ? {
|
|
159
204
|
name: 'mysql',
|
|
160
205
|
tag: mysql.version
|
|
161
206
|
} : {
|
|
162
207
|
name: 'mariadb',
|
|
163
208
|
tag: mariadb.version
|
|
164
209
|
},
|
|
165
|
-
name: !
|
|
210
|
+
name: !isArm ? `${ prefix }_mysql` : `${ prefix }_mariadb`
|
|
166
211
|
},
|
|
167
212
|
elasticsearch: {
|
|
168
213
|
_: 'ElasticSearch',
|
|
@@ -195,6 +240,34 @@ module.exports = async ({ configuration, ssl, host }, config) => {
|
|
|
195
240
|
);
|
|
196
241
|
}
|
|
197
242
|
|
|
243
|
+
if (varnish.enabled) {
|
|
244
|
+
dockerConfig.varnish = {
|
|
245
|
+
_: 'Varnish',
|
|
246
|
+
image: `varnish:${ varnish.version }`,
|
|
247
|
+
imageDetails: {
|
|
248
|
+
name: 'varnish',
|
|
249
|
+
tag: varnish.version
|
|
250
|
+
},
|
|
251
|
+
name: `${ prefix }_varnish`,
|
|
252
|
+
mountVolumes: [
|
|
253
|
+
`${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
|
|
254
|
+
],
|
|
255
|
+
ports: isNotNativeLinux ? [
|
|
256
|
+
`${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.varnish }:80`
|
|
257
|
+
] : [],
|
|
258
|
+
env: {
|
|
259
|
+
VARNISH_SIZE: '2G'
|
|
260
|
+
},
|
|
261
|
+
restart: 'on-failure:30',
|
|
262
|
+
network: isNotNativeLinux ? network.name : 'host',
|
|
263
|
+
// eslint-disable-next-line max-len
|
|
264
|
+
command: `/bin/bash -c "varnishd -a :${ isNotNativeLinux ? 80 : ports.varnish } -t 600 -f /etc/varnish/default.vcl -s malloc,512m && varnishlog"`,
|
|
265
|
+
tmpfs: [
|
|
266
|
+
'/var/lib/varnish:exec'
|
|
267
|
+
]
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
198
271
|
return dockerConfig;
|
|
199
272
|
};
|
|
200
273
|
|
|
@@ -26,6 +26,10 @@ const getAvailablePorts = () => ({
|
|
|
26
26
|
'utf-8'
|
|
27
27
|
)
|
|
28
28
|
);
|
|
29
|
+
if (!ports.sslTerminator) {
|
|
30
|
+
ports.sslTerminator = ports.app;
|
|
31
|
+
ports.app = defaultPorts.app;
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
const {
|
|
31
35
|
systemConfiguration: {
|
|
@@ -41,7 +45,7 @@ const getAvailablePorts = () => ({
|
|
|
41
45
|
if (!isPortAvailable) {
|
|
42
46
|
throw new Error(`Port ${ctx.port} is not available`);
|
|
43
47
|
} else {
|
|
44
|
-
availablePorts.
|
|
48
|
+
availablePorts.sslTerminator = ctx.port;
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -51,7 +55,7 @@ const getAvailablePorts = () => ({
|
|
|
51
55
|
});
|
|
52
56
|
|
|
53
57
|
/**
|
|
54
|
-
* @type {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
58
|
+
* @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
55
59
|
*/
|
|
56
60
|
const getCachedPorts = () => ({
|
|
57
61
|
title: 'Getting cached ports',
|
|
@@ -65,6 +69,7 @@ const getCachedPorts = () => ({
|
|
|
65
69
|
'utf-8'
|
|
66
70
|
)
|
|
67
71
|
);
|
|
72
|
+
ctx.cachedPorts = { ...ports };
|
|
68
73
|
} else {
|
|
69
74
|
ports = { ...defaultPorts };
|
|
70
75
|
}
|
|
@@ -3,10 +3,8 @@ alias magento="php $PWD/bin/magento"
|
|
|
3
3
|
alias m="magento"
|
|
4
4
|
alias composer="php $PWD/node_modules/.create-magento-app-cache/composer/composer.phar"
|
|
5
5
|
alias c="composer"
|
|
6
|
+
<% if (it.varnishEnabled) { %>
|
|
7
|
+
alias cvc="npm run exec varnish varnishadm ban req.url '~ /' && echo 'Varnish cache cleared!'"
|
|
8
|
+
<% } %>
|
|
6
9
|
|
|
7
10
|
export BASH_SILENCE_DEPRECATION_WARNING=1
|
|
8
|
-
|
|
9
|
-
echo ""
|
|
10
|
-
echo "Available aliases: php, magento, composer"
|
|
11
|
-
echo "Available shortcuts: magento -> m, composer -> c"
|
|
12
|
-
echo ""
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
real_ip_header X-Forwarded-For;
|
|
2
|
-
set_real_ip_from 10.0.0.0/8;
|
|
3
|
-
set_real_ip_from 172.0.0.0/8;
|
|
4
|
-
real_ip_recursive on;
|
|
5
|
-
|
|
6
1
|
upstream fastcgi_backend {
|
|
7
2
|
# use tcp connection
|
|
8
3
|
server <%= it.hostMachine %>:<%= it.ports.fpm %>;
|
|
@@ -10,16 +5,7 @@ upstream fastcgi_backend {
|
|
|
10
5
|
|
|
11
6
|
server {
|
|
12
7
|
listen <%= it.hostPort %>;
|
|
13
|
-
<% if (it.config.ssl.enabled) { %>listen 443 ssl;<% } %>
|
|
14
|
-
|
|
15
|
-
<% if (it.config.ssl.enabled) { %>server_name <%= it.networkToBindTo %>;
|
|
16
|
-
|
|
17
|
-
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
18
|
-
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
19
|
-
ssl_protocols TLSv1.2;<% } else if (it.config.host) { %>server_name <%= it.config.host %>;
|
|
20
|
-
<% } else { %>
|
|
21
8
|
server_name _;
|
|
22
|
-
<% } %>
|
|
23
9
|
|
|
24
10
|
set $MAGE_ROOT <%= it.mageRoot %>;
|
|
25
11
|
resolver 127.0.0.11;
|
|
@@ -1812,7 +1812,7 @@ ldap.max_links = -1
|
|
|
1812
1812
|
|
|
1813
1813
|
[opcache]
|
|
1814
1814
|
; Determines if Zend OPCache is enabled
|
|
1815
|
-
|
|
1815
|
+
opcache.enable=1
|
|
1816
1816
|
|
|
1817
1817
|
; Determines if Zend OPCache is enabled for the CLI version of PHP
|
|
1818
1818
|
;opcache.enable_cli=0
|
|
@@ -1838,19 +1838,19 @@ ldap.max_links = -1
|
|
|
1838
1838
|
|
|
1839
1839
|
; When disabled, you must reset the OPcache manually or restart the
|
|
1840
1840
|
; webserver for changes to the filesystem to take effect.
|
|
1841
|
-
|
|
1841
|
+
opcache.validate_timestamps=1
|
|
1842
1842
|
|
|
1843
1843
|
; How often (in seconds) to check file timestamps for changes to the shared
|
|
1844
1844
|
; memory storage allocation. ("1" means validate once per second, but only
|
|
1845
1845
|
; once per request. "0" means always validate)
|
|
1846
|
-
|
|
1846
|
+
opcache.revalidate_freq=2
|
|
1847
1847
|
|
|
1848
1848
|
; Enables or disables file search in include_path optimization
|
|
1849
1849
|
;opcache.revalidate_path=0
|
|
1850
1850
|
|
|
1851
1851
|
; If disabled, all PHPDoc comments are dropped from the code to reduce the
|
|
1852
1852
|
; size of the optimized code.
|
|
1853
|
-
|
|
1853
|
+
opcache.save_comments=1
|
|
1854
1854
|
|
|
1855
1855
|
; If enabled, compilation warnings (including notices and deprecations) will
|
|
1856
1856
|
; be recorded and replayed each time a file is included. Otherwise, compilation
|
|
@@ -2038,3 +2038,5 @@ xdebug.mode=off
|
|
|
2038
2038
|
<% } %>
|
|
2039
2039
|
|
|
2040
2040
|
<% } %>
|
|
2041
|
+
|
|
2042
|
+
apc.enabled=1
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
real_ip_header X-Forwarded-For;
|
|
2
|
+
set_real_ip_from 10.0.0.0/8;
|
|
3
|
+
set_real_ip_from 172.0.0.0/8;
|
|
4
|
+
real_ip_recursive on;
|
|
5
|
+
|
|
6
|
+
server {
|
|
7
|
+
listen <%= it.hostPort %>;
|
|
8
|
+
<% if (it.config.ssl.enabled) { %> listen 443 ssl;
|
|
9
|
+
server_name <%= it.networkToBindTo %>;
|
|
10
|
+
|
|
11
|
+
ssl_certificate /etc/nginx/conf.d/ssl_certificate.pem;
|
|
12
|
+
ssl_certificate_key /etc/nginx/conf.d/ssl_certificate-key.pem;
|
|
13
|
+
ssl_protocols TLSv1.2;<% } %>
|
|
14
|
+
|
|
15
|
+
server_name <% if (it.config.host) { %><%= it.config.host %><% } else { %>_<% } %>;
|
|
16
|
+
|
|
17
|
+
location / {
|
|
18
|
+
proxy_buffer_size 128k;
|
|
19
|
+
proxy_buffers 4 256k;
|
|
20
|
+
proxy_busy_buffers_size 256k;
|
|
21
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
22
|
+
proxy_set_header X-Forwarded-For $remote_addr;
|
|
23
|
+
proxy_set_header Host $http_host;
|
|
24
|
+
|
|
25
|
+
proxy_pass http://<%= it.hostMachine %>:<% if (it.config.configuration.varnish.enabled) { %><%= it.ports.varnish %><% } else { %><%= it.ports.app %><% } %>;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
|
|
2
|
+
vcl 4.0;
|
|
3
|
+
|
|
4
|
+
import std;
|
|
5
|
+
# The minimal Varnish version is 6.0
|
|
6
|
+
# For SSL offloading, pass the following header in your proxy server or load balancer: 'X-Forwarded-Proto: https'
|
|
7
|
+
|
|
8
|
+
backend default {
|
|
9
|
+
.host = "<%= it.hostMachine %>";
|
|
10
|
+
.host_header = "Host: localhost";
|
|
11
|
+
.port = "<%= it.nginxPort %>";
|
|
12
|
+
.first_byte_timeout = 600s;
|
|
13
|
+
.probe = {
|
|
14
|
+
# .url = "/health_check.php";
|
|
15
|
+
.request =
|
|
16
|
+
"GET /health_check.php HTTP/1.1"
|
|
17
|
+
"Host: localhost"
|
|
18
|
+
"Connection: close"
|
|
19
|
+
"User-Agent: Varnish Health Probe";
|
|
20
|
+
.interval = 10s;
|
|
21
|
+
.timeout = 5s;
|
|
22
|
+
.window = 5;
|
|
23
|
+
.threshold = 3;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
acl purge {
|
|
28
|
+
"<%= it.hostMachine %>";
|
|
29
|
+
"localhost";
|
|
30
|
+
"172.0.0.0"/8;
|
|
31
|
+
"192.168.0.0"/16;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
sub vcl_recv {
|
|
35
|
+
if (req.restarts > 0) {
|
|
36
|
+
set req.hash_always_miss = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (req.method == "PURGE") {
|
|
40
|
+
if (client.ip !~ purge) {
|
|
41
|
+
return (synth(405, "Method not allowed"));
|
|
42
|
+
}
|
|
43
|
+
# To use the X-Pool header for purging varnish during automated deployments, make sure the X-Pool header
|
|
44
|
+
# has been added to the response in your backend server config. This is used, for example, by the
|
|
45
|
+
# capistrano-magento2 gem for purging old content from varnish during it's deploy routine.
|
|
46
|
+
if (!req.http.X-Magento-Tags-Pattern && !req.http.X-Pool) {
|
|
47
|
+
return (synth(400, "X-Magento-Tags-Pattern or X-Pool header required"));
|
|
48
|
+
}
|
|
49
|
+
if (req.http.X-Magento-Tags-Pattern) {
|
|
50
|
+
ban("obj.http.X-Magento-Tags ~ " + req.http.X-Magento-Tags-Pattern);
|
|
51
|
+
}
|
|
52
|
+
if (req.http.X-Pool) {
|
|
53
|
+
ban("obj.http.X-Pool ~ " + req.http.X-Pool);
|
|
54
|
+
}
|
|
55
|
+
return (synth(200, "Purged"));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (req.method != "GET" &&
|
|
59
|
+
req.method != "HEAD" &&
|
|
60
|
+
req.method != "PUT" &&
|
|
61
|
+
req.method != "POST" &&
|
|
62
|
+
req.method != "TRACE" &&
|
|
63
|
+
req.method != "OPTIONS" &&
|
|
64
|
+
req.method != "DELETE") {
|
|
65
|
+
/* Non-RFC2616 or CONNECT which is weird. */
|
|
66
|
+
return (pipe);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# We only deal with GET and HEAD by default
|
|
70
|
+
if (req.method != "GET" && req.method != "HEAD") {
|
|
71
|
+
return (pass);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Bypass customer, shopping cart, checkout
|
|
75
|
+
if (req.url ~ "/customer" || req.url ~ "/checkout") {
|
|
76
|
+
return (pass);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Bypass health check requests
|
|
80
|
+
if (req.url ~ "^/(pub/)?(health_check.php)$") {
|
|
81
|
+
return (pass);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# Set initial grace period usage status
|
|
85
|
+
set req.http.grace = "none";
|
|
86
|
+
|
|
87
|
+
# normalize url in case of leading HTTP scheme and domain
|
|
88
|
+
set req.url = regsub(req.url, "^http[s]?://", "");
|
|
89
|
+
|
|
90
|
+
# collect all cookies
|
|
91
|
+
std.collect(req.http.Cookie);
|
|
92
|
+
|
|
93
|
+
# Compression filter. See https://www.varnish-cache.org/trac/wiki/FAQ/Compression
|
|
94
|
+
if (req.http.Accept-Encoding) {
|
|
95
|
+
if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") {
|
|
96
|
+
# No point in compressing these
|
|
97
|
+
unset req.http.Accept-Encoding;
|
|
98
|
+
} elsif (req.http.Accept-Encoding ~ "gzip") {
|
|
99
|
+
set req.http.Accept-Encoding = "gzip";
|
|
100
|
+
} elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") {
|
|
101
|
+
set req.http.Accept-Encoding = "deflate";
|
|
102
|
+
} else {
|
|
103
|
+
# unknown algorithm
|
|
104
|
+
unset req.http.Accept-Encoding;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
# Remove all marketing get parameters to minimize the cache objects
|
|
109
|
+
if (req.url ~ "(\?|&)(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=") {
|
|
110
|
+
set req.url = regsuball(req.url, "(gclid|cx|ie|cof|siteurl|zanpid|origin|fbclid|mc_[a-z]+|utm_[a-z]+|_bta_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
|
|
111
|
+
set req.url = regsub(req.url, "[?|&]+$", "");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
# Static files caching
|
|
115
|
+
if (req.url ~ "^/(pub/)?(media|static)/") {
|
|
116
|
+
# Static files should not be cached by default
|
|
117
|
+
return (pass);
|
|
118
|
+
|
|
119
|
+
# But if you use a few locales and don't use CDN you can enable caching static files by commenting previous line (#return (pass);) and uncommenting next 3 lines
|
|
120
|
+
#unset req.http.Https;
|
|
121
|
+
#unset req.http.X-Forwarded-Proto;
|
|
122
|
+
#unset req.http.Cookie;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Authenticated GraphQL requests should not be cached by default
|
|
126
|
+
if (req.url ~ "/graphql" && req.http.Authorization ~ "^Bearer") {
|
|
127
|
+
return (pass);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (hash);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
sub vcl_hash {
|
|
134
|
+
if (req.http.cookie ~ "X-Magento-Vary=") {
|
|
135
|
+
hash_data(regsub(req.http.cookie, "^.*?X-Magento-Vary=([^;]+);*.*$", "\1"));
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# To make sure http users don't see ssl warning
|
|
139
|
+
if (req.http.X-Forwarded-Proto) {
|
|
140
|
+
hash_data(req.http.X-Forwarded-Proto);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (req.url ~ "/graphql") {
|
|
144
|
+
call process_graphql_headers;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
sub process_graphql_headers {
|
|
149
|
+
if (req.http.Store) {
|
|
150
|
+
hash_data(req.http.Store);
|
|
151
|
+
}
|
|
152
|
+
if (req.http.Content-Currency) {
|
|
153
|
+
hash_data(req.http.Content-Currency);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
sub vcl_backend_response {
|
|
158
|
+
|
|
159
|
+
set beresp.grace = 3d;
|
|
160
|
+
|
|
161
|
+
if (beresp.http.content-type ~ "text") {
|
|
162
|
+
set beresp.do_esi = true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (bereq.url ~ "\.js$" || beresp.http.content-type ~ "text") {
|
|
166
|
+
set beresp.do_gzip = true;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (beresp.http.X-Magento-Debug) {
|
|
170
|
+
set beresp.http.X-Magento-Cache-Control = beresp.http.Cache-Control;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
# cache only successfully responses and 404s
|
|
174
|
+
if (beresp.status != 200 && beresp.status != 404) {
|
|
175
|
+
set beresp.ttl = 0s;
|
|
176
|
+
set beresp.uncacheable = true;
|
|
177
|
+
return (deliver);
|
|
178
|
+
} elsif (beresp.http.Cache-Control ~ "private") {
|
|
179
|
+
set beresp.uncacheable = true;
|
|
180
|
+
set beresp.ttl = 86400s;
|
|
181
|
+
return (deliver);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
# validate if we need to cache it and prevent from setting cookie
|
|
185
|
+
if (beresp.ttl > 0s && (bereq.method == "GET" || bereq.method == "HEAD")) {
|
|
186
|
+
unset beresp.http.set-cookie;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
# If page is not cacheable then bypass varnish for 2 minutes as Hit-For-Pass
|
|
190
|
+
if (beresp.ttl <= 0s ||
|
|
191
|
+
beresp.http.Surrogate-control ~ "no-store" ||
|
|
192
|
+
(!beresp.http.Surrogate-Control &&
|
|
193
|
+
beresp.http.Cache-Control ~ "no-cache|no-store") ||
|
|
194
|
+
beresp.http.Vary == "*") {
|
|
195
|
+
# Mark as Hit-For-Pass for the next 2 minutes
|
|
196
|
+
set beresp.ttl = 120s;
|
|
197
|
+
set beresp.uncacheable = true;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return (deliver);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
sub vcl_deliver {
|
|
204
|
+
if (resp.http.X-Magento-Debug) {
|
|
205
|
+
if (resp.http.x-varnish ~ " ") {
|
|
206
|
+
set resp.http.X-Magento-Cache-Debug = "HIT";
|
|
207
|
+
set resp.http.Grace = req.http.grace;
|
|
208
|
+
} else {
|
|
209
|
+
set resp.http.X-Magento-Cache-Debug = "MISS";
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
unset resp.http.Age;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
# Not letting browser to cache non-static files.
|
|
216
|
+
if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(pub/)?(media|static)/") {
|
|
217
|
+
set resp.http.Pragma = "no-cache";
|
|
218
|
+
set resp.http.Expires = "-1";
|
|
219
|
+
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
unset resp.http.X-Magento-Debug;
|
|
223
|
+
unset resp.http.X-Magento-Tags;
|
|
224
|
+
unset resp.http.X-Powered-By;
|
|
225
|
+
unset resp.http.Server;
|
|
226
|
+
unset resp.http.X-Varnish;
|
|
227
|
+
unset resp.http.Via;
|
|
228
|
+
unset resp.http.Link;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
sub vcl_hit {
|
|
232
|
+
if (obj.ttl >= 0s) {
|
|
233
|
+
# Hit within TTL period
|
|
234
|
+
return (deliver);
|
|
235
|
+
}
|
|
236
|
+
if (std.healthy(req.backend_hint)) {
|
|
237
|
+
if (obj.ttl + 300s > 0s) {
|
|
238
|
+
# Hit after TTL expiration, but within grace period
|
|
239
|
+
set req.http.grace = "normal (healthy server)";
|
|
240
|
+
return (deliver);
|
|
241
|
+
} else {
|
|
242
|
+
# Hit after TTL and grace expiration
|
|
243
|
+
return (restart);
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
# server is not healthy, retrieve from cache
|
|
247
|
+
set req.http.grace = "unlimited (unhealthy server)";
|
|
248
|
+
return (deliver);
|
|
249
|
+
}
|
|
250
|
+
}
|