Loading README.md +5 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ - Python 3.6 - [Pipenv](https://pipenv.org) - [Docker](https://www.docker.com/) (Only needed for running the lighthouse and sitespeed tests) - [direnv](http://direnv.net/) (Just for ease of use) ## Usage Loading @@ -17,10 +20,12 @@ Available commands: build Build local version of site clean Remove generated files dev Auto-regenerate files and serve at http://localhost:8080/ lighthouse Run Chrome's Lighthouse report against the local dev server preview Build production version of site publish Publish to production via rsync regenerate Automatically regenerate site upon file modification serve Serve site at http://localhost:8080/ sitespeed Run sitespeed test against the local dev server ``` Loading fabfile.py +34 −3 Original line number Diff line number Diff line from fabric.api import lcd, env, local, hosts from fabric.api import lcd, env, local, hosts, warn_only import fabric.contrib.project as project import multiprocessing import os env.use_ssh_config = True # Local path configuration (can be absolute or relative to fabfile) env.deploy_path = 'output' DEPLOY_PATH = env.deploy_path Loading @@ -10,10 +12,12 @@ DEPLOY_PATH = env.deploy_path production = 'www.shore.co.il' dest_path = '/var/www/htdocs/www.shore.co.il/blog/' UID = os.getuid() def clean(): """Remove generated files""" local(f'rm -r __pycache__/ {DEPLOY_PATH}/*') local(f'rm -rf __pycache__/ {DEPLOY_PATH}/* sitespeed-result/ lighthouse-result/') def build(): Loading @@ -34,9 +38,11 @@ def serve(): def dev(): """Auto-regenerate files and serve at http://localhost:8080/""" server_process = multiprocessing.Process(target=serve) server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() regenerate() server_process.terminate() server_process.join(timeout=3) def preview(): Loading @@ -55,3 +61,28 @@ def publish(): delete=True, extra_opts='-c', ) def sitespeed(): """Run sitespeed test against the local dev server""" build() with warn_only(): local('docker run --rm --privileged --net=host gliderlabs/hostlocal') server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() local(f'docker run --rm --shm-size=1g -u {UID} -v "$PWD:/sitespeed.io" sitespeedio/sitespeed.io http://169.254.255.254:8080/') server_process.terminate() server_process.join(timeout=3) def lighthouse(): """Run Chrome's Lighthouse report against the local dev server""" build() with warn_only(): local('docker run --rm --privileged --net=host gliderlabs/hostlocal') server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() local('mkdir -p lighthouse-result') local('docker run --rm -u {UID} -v "$PWD/lighthouse-result:/home/chrome/reports" --cap-add=SYS_ADMIN --user=1000 justinribeiro/lighthouse lighthouse --chrome-flags="--headless --no-sandbox --disable-gpu" http://169.254.255.254:8080/') server_process.terminate() server_process.join(timeout=3) Loading
README.md +5 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,9 @@ - Python 3.6 - [Pipenv](https://pipenv.org) - [Docker](https://www.docker.com/) (Only needed for running the lighthouse and sitespeed tests) - [direnv](http://direnv.net/) (Just for ease of use) ## Usage Loading @@ -17,10 +20,12 @@ Available commands: build Build local version of site clean Remove generated files dev Auto-regenerate files and serve at http://localhost:8080/ lighthouse Run Chrome's Lighthouse report against the local dev server preview Build production version of site publish Publish to production via rsync regenerate Automatically regenerate site upon file modification serve Serve site at http://localhost:8080/ sitespeed Run sitespeed test against the local dev server ``` Loading
fabfile.py +34 −3 Original line number Diff line number Diff line from fabric.api import lcd, env, local, hosts from fabric.api import lcd, env, local, hosts, warn_only import fabric.contrib.project as project import multiprocessing import os env.use_ssh_config = True # Local path configuration (can be absolute or relative to fabfile) env.deploy_path = 'output' DEPLOY_PATH = env.deploy_path Loading @@ -10,10 +12,12 @@ DEPLOY_PATH = env.deploy_path production = 'www.shore.co.il' dest_path = '/var/www/htdocs/www.shore.co.il/blog/' UID = os.getuid() def clean(): """Remove generated files""" local(f'rm -r __pycache__/ {DEPLOY_PATH}/*') local(f'rm -rf __pycache__/ {DEPLOY_PATH}/* sitespeed-result/ lighthouse-result/') def build(): Loading @@ -34,9 +38,11 @@ def serve(): def dev(): """Auto-regenerate files and serve at http://localhost:8080/""" server_process = multiprocessing.Process(target=serve) server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() regenerate() server_process.terminate() server_process.join(timeout=3) def preview(): Loading @@ -55,3 +61,28 @@ def publish(): delete=True, extra_opts='-c', ) def sitespeed(): """Run sitespeed test against the local dev server""" build() with warn_only(): local('docker run --rm --privileged --net=host gliderlabs/hostlocal') server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() local(f'docker run --rm --shm-size=1g -u {UID} -v "$PWD:/sitespeed.io" sitespeedio/sitespeed.io http://169.254.255.254:8080/') server_process.terminate() server_process.join(timeout=3) def lighthouse(): """Run Chrome's Lighthouse report against the local dev server""" build() with warn_only(): local('docker run --rm --privileged --net=host gliderlabs/hostlocal') server_process = multiprocessing.Process(target=serve, daemon=True) server_process.start() local('mkdir -p lighthouse-result') local('docker run --rm -u {UID} -v "$PWD/lighthouse-result:/home/chrome/reports" --cap-add=SYS_ADMIN --user=1000 justinribeiro/lighthouse lighthouse --chrome-flags="--headless --no-sandbox --disable-gpu" http://169.254.255.254:8080/') server_process.terminate() server_process.join(timeout=3)