Skip to content
Closed
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: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ LOCAL_PORT=8889
# Where to run WordPress from. Valid options are 'src' and 'build'.
LOCAL_DIR=src

# Whether or not to enable text compression (gzip) in the web server.
# Valid options are 'on' and 'off'.
LOCAL_NGINX_COMPRESSION=off

# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
LOCAL_PHP=latest

Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ services:

environment:
LOCAL_DIR: ${LOCAL_DIR-src}
LOCAL_NGINX_COMPRESSION: ${LOCAL_NGINX_COMPRESSION:-off}

volumes:
- ./tools/local-env/default.template:/etc/nginx/conf.d/default.template
- ./:/var/www

# Load our config file, substituting environment variables into the config.
command: /bin/sh -c "envsubst '$$LOCAL_DIR' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"
command: /bin/sh -c "envsubst '$$LOCAL_DIR $$LOCAL_NGINX_COMPRESSION' < /etc/nginx/conf.d/default.template > /etc/nginx/conf.d/default.conf && exec nginx -g 'daemon off;'"

depends_on:
php:
Expand Down
15 changes: 15 additions & 0 deletions tools/local-env/default.template
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ server {

absolute_redirect off;

gzip ${LOCAL_NGINX_COMPRESSION};
gzip_vary on;
gzip_proxied any;
gzip_comp_level 5;
gzip_min_length 256;
gzip_types
application/javascript
text/javascript
application/json
application/xml
application/rss+xml
text/css
text/plain
image/svg+xml;

if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
Expand Down