|
4 | 4 |
|
5 | 5 | namespace Hypernode\DeployConfiguration; |
6 | 6 |
|
7 | | -use function Deployer\after; |
8 | | -use function Deployer\run; |
9 | | -use function Deployer\task; |
10 | | -use function Deployer\test; |
| 7 | +use function Deployer\{run, task, test, within, set}; |
11 | 8 |
|
12 | 9 | $DOCKER_HOST = '172.17.0.2'; |
13 | 10 | $DOCKER_WEBROOT = sprintf('/data/web/apps/%s/current/pub', $DOCKER_HOST); |
|
74 | 71 | run('cp {{release_path}}/etc/nginx/server.redirects.conf /data/web/nginx/server.redirects.conf'); |
75 | 72 | }); |
76 | 73 |
|
| 74 | +// This will pre-compress files using brotli compression so we can serve them directly from nginx |
| 75 | +// without needing to compress them on-the-fly. |
| 76 | +task('build:compress:brotli', function () { |
| 77 | + set('brotli_compression_level', 11); |
| 78 | + |
| 79 | + run('apt update && apt install brotli -y'); |
| 80 | + within('{{release_or_current_path}}/docs/_build/html', function () { |
| 81 | + run('find . -name "*.html" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 82 | + run('find . -name "*.css" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 83 | + run('find . -name "*.js" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 84 | + run('find . -name "*.svg" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 85 | + run('find . -name "*.png" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 86 | + run('find . -name "*.jpg" -type f -exec brotli -f -q {{brotli_compression_level}} {} \\;'); |
| 87 | + }); |
| 88 | +}); |
| 89 | + |
77 | 90 | $configuration = new Configuration(); |
78 | 91 | $configuration->addBuildTask('node:build:scss'); |
79 | 92 | $configuration->addBuildTask('python:venv:create'); |
80 | 93 | $configuration->addBuildTask('python:venv:requirements'); |
81 | 94 | $configuration->addBuildTask('python:build_documentation'); |
82 | 95 | $configuration->addBuildTask('python:generate_redirects'); |
| 96 | +$configuration->addBuildTask('build:compress:brotli'); |
83 | 97 | $configuration->addDeployTask('deploy:disable_public'); |
84 | 98 | $configuration->addDeployTask('deploy:hmv_docker'); |
85 | 99 | $configuration->addDeployTask('deploy:docs_vhost:acceptance'); |
|
0 commit comments