Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Include the surge caching plugin by default. #121

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ NONCE_SALT=__SECRET__
WP_DEBUG=true
WP_DEBUG_DISPLAY=true

# Caching Flags
WP_CACHE=true

# Should always be true in production
DISALLOW_FILE_EDIT=true


# Docker compose vars

# Linux only
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/wp-content/vendor
/wp-content/db.php
/wp-content/object-cache.php
/wp-content/advanced-cache.php
/wp-content/cache

/wp-content/mu-plugins/000-boxuk/cache/*
!/wp-content/mu-plugins/000-boxuk/cache/.gitkeep
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"symfony/yaml": "^5.0",
"wpackagist-plugin/advanced-caching": "@dev",
"wpackagist-plugin/memcached": "^4.0",
"wpackagist-plugin/query-monitor": "^3.5"
"wpackagist-plugin/query-monitor": "^3.5",
"wpackagist-plugin/surge": "^1.0"
},
"require-dev": {
"jenko/wp-plugin-trouble-detector": "^0.1.0",
Expand Down
20 changes: 19 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ RUN set -eux; \
# Blackfire
# https://blackfire.io/docs/integrations/docker/php-docker
RUN set -eux; \
version="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")"; \
curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s "https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version"; \
mkdir -p /tmp/blackfire; \
tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire; \
mv /tmp/blackfire/blackfire-*.so "$(php -r "echo ini_get('extension_dir');")"/blackfire.so; \
rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz;
version="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")" \
&& architecture="$(uname -m)" \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s "https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version" \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so "$(php -r "echo ini_get ('extension_dir');")/blackfire.so" \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8307\n" > "$PHP_INI_DIR/conf.d/blackfire.ini" \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz;

# Set groups and user when on linux
RUN set -eux; \
Expand Down
14 changes: 8 additions & 6 deletions docker/app/Dockerfile_xdebug
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ RUN set -eux; \
# Blackfire
# https://blackfire.io/docs/integrations/docker/php-docker
RUN set -eux; \
version="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")"; \
curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s "https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version"; \
mkdir -p /tmp/blackfire; \
tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire; \
mv /tmp/blackfire/blackfire-*.so "$(php -r "echo ini_get('extension_dir');")"/blackfire.so; \
rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz;
version="$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;")" \
&& architecture="$(uname -m)" \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s "https://blackfire.io/api/v1/releases/probe/php/linux/$architecture/$version" \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so "$(php -r "echo ini_get ('extension_dir');")/blackfire.so" \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8307\n" > "$PHP_INI_DIR/conf.d/blackfire.ini" \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz;

# Set groups and user when on linux
RUN set -eux; \
Expand Down
8 changes: 8 additions & 0 deletions docs/dev/vip.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ add_filter('timber/cache/mode', function() {
add_filter( 'timber/allow_fs_write', '__return_false' );
```

## Remove surge plugin and related files/folders

Surge won't work on VIP environments as it needs the ability to write to the file system. [VIP has its own page caching anyhow](https://docs.wpvip.com/technical-references/caching/page-cache/).

`composer remove wpackagist-plugin/surge`
Comment on lines +73 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything that can be done to detect the VIP environment and switch this off in those circumstances?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this automatically in the vip-install, although it may still be useful to have installed locally. I think it'd likely be part of our deployment script to remove as part of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which (at the moment at least) I think is outside of the scope of this repository.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's reasonable.


> Remember to remove any related files or folders too, such as `wp-content/advanced-cache.php` and the `wp-content/cache` directory.

## Ordering of initialisation files

VIP uses a [000-vip-init.php](https://github.com/Automattic/vip-go-mu-plugins/blob/master/000-vip-init.php) file to initialise
Expand Down
1 change: 1 addition & 0 deletions site-state.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ settings:
active_plugins:
- advanced-caching/advanced-caching.php
- query-monitor/query-monitor.php
- surge/surge.php
users:
admin:
display_name: admin
Expand Down
3 changes: 3 additions & 0 deletions wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@

define( 'DISALLOW_FILE_EDIT', ! empty( $_ENV['DISALLOW_FILE_EDIT'] ) ? filter_var( $_ENV['DISALLOW_FILE_EDIT'], FILTER_VALIDATE_BOOLEAN ) : true );

// Enable cache by default.
define( 'WP_CACHE', isset( $_ENV['WP_CACHE'] ) ? filter_var( $_ENV['WP_CACHE'], FILTER_VALIDATE_BOOLEAN ) : true );

/**
* Memcached servers
*/
Expand Down