Skip to content

Commit ef9498b

Browse files
authored
Merge pull request #1074 from markshust/feature/fix-performance-issue-spx
2 parents 45ce137 + 2820aed commit ef9498b

File tree

7 files changed

+59
-7
lines changed

7 files changed

+59
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2020
- New `bin/setup-pwa-studio-sampledata` command to install Magento PWA Studio sample data, facilitating easier PWA development setups [#1045](https://github.com/markshust/docker-magento/pull/1045).
2121
- New `bin/deploy` script to deply Magento in pipeline [PR #926](https://github.com/markshust/docker-magento/pull/926).
2222
- New `bin/magento-version` script which outputs current Magento version [PR #931](https://github.com/markshust/docker-magento/pull/931).
23+
- New `bin/spx` script to enable or disable SPX [PR #1074](https://github.com/markshust/docker-magento/pull/1074).
2324

2425
### Updated
2526
- Node.js to version 20.x LTS [PR #1071](https://github.com/markshust/docker-magento/pull/1071).

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ It is recommended to keep your root docker config files in one repository, and y
318318
- `bin/setup-pwa-studio-sampledata`: This script makes it easier to install Venia sample data. Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio-sampledata magento.test`.
319319
- `bin/setup-ssl`: Generate an SSL certificate for one or more domains. Ex. `bin/setup-ssl magento.test foo.test`
320320
- `bin/setup-ssl-ca`: Generate a certificate authority and copy it to the host.
321+
- `bin/spx`: Disable or enable output compression to enable or disbale SPX. Accepts params `disable` (default) or `enable`. Ex. `bin/spx enable`
321322
- `bin/start`: Start all containers, good practice to use this instead of `docker-compose up -d`, as it may contain additional helpers.
322323
- `bin/status`: Check the container status.
323324
- `bin/stop`: Stop all project containers.

compose/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ help:
3131
@echo "$(call format,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')"
3232
@echo "$(call format,devconsole,'Alias for n98-magerun2 dev:console.')"
3333
@echo "$(call format,devtools-cli-check,'Check & install the CLI devtools if missing from system.')"
34-
@echo "$(call format,docker-stats,'Display status for CPU, memory usage, and memory limit of currently-running Docker containers.')"
34+
@echo "$(call format,docker-stats,'Display status for CPU$(comma) memory usage$(comma) and memory limit of currently-running Docker containers.')"
3535
@echo "$(call format,download,'Download & extract specific Magento version to the src directory.')"
3636
@echo "$(call format,fixowns,'This will fix filesystem ownerships within the container.')"
3737
@echo "$(call format,fixperms,'This will fix filesystem permissions within the container.')"
@@ -59,6 +59,7 @@ help:
5959
@echo "$(call format,setup-pwa-studio,'(BETA) Install PWA Studio.')"
6060
@echo "$(call format,setup-ssl,'Generate an SSL certificate for one or more domains.')"
6161
@echo "$(call format,setup-ssl-ca,'Generate a certificate authority and copy it to the host.')"
62+
@echo "$(call format,spx,'Disable or enable output compression to enable or disbale SPX.')"
6263
@echo "$(call format,start,'Start all containers.')"
6364
@echo "$(call format,status,'Check the container status.')"
6465
@echo "$(call format,stop,'Stop all containers.')"

compose/bin/spx

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'zlib.output_compression = 1');
4+
5+
spx_status() {
6+
if [[ $S == 1 ]]; then
7+
echo "Output compression is enabled, so you cannot currently debug with SPX."
8+
else
9+
echo "Output compression is disabled, so you can currently debug with SPX."
10+
fi
11+
}
12+
13+
spx_toggle() {
14+
if [[ $S == 1 ]]; then
15+
spx_enable
16+
else
17+
spx_disable
18+
fi
19+
}
20+
21+
spx_enable() {
22+
if [[ $S == 1 ]]; then
23+
bin/root sed -i -e 's/^zlib.output_compression = 1/zlib.output_compression = 0/g' /usr/local/etc/php/php.ini
24+
sleep 1
25+
bin/restart phpfpm
26+
echo "Output compression is now disabled, so you can start debugging with SPX."
27+
else
28+
echo "Output compression is already disabled, so you can start debugging with SPX."
29+
fi
30+
}
31+
32+
spx_disable() {
33+
if [[ $S == 0 ]]; then
34+
bin/root sed -i -e 's/^zlib.output_compression = 0/zlib.output_compression = 1/g' /usr/local/etc/php/php.ini
35+
sleep 1
36+
bin/restart phpfpm
37+
echo "Output compression is now enabled, so you can no longer debug with SPX."
38+
else
39+
echo "Output compression is already enabled, so you can no longer debug with SPX."
40+
fi
41+
}
42+
43+
firstArgLetter="$(echo "$1" | head -c 1)"
44+
45+
if [[ $firstArgLetter == "d" ]]; then
46+
spx_disable
47+
elif [[ $firstArgLetter == "e" ]]; then
48+
spx_enable
49+
elif [[ $firstArgLetter == "t" ]]; then
50+
spx_toggle
51+
elif [[ $firstArgLetter == "s" ]]; then
52+
spx_status
53+
else
54+
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/spx status\n"
55+
fi

images/php/8.1/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

images/php/8.2/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

images/php/8.3/conf/spx.ini

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
zlib.output_compression = 0
2-
31
extension = /usr/lib/php-spx/modules/spx.so
42
spx.http_enabled = 1
53
spx.http_key = "dev"

0 commit comments

Comments
 (0)