Skip to content

Commit 4b624a7

Browse files
committed
Speed up site build
Middleman uses a dope/weird system that implements types in Ruby using metaprogramming (I highly recommend watching the talk by middleman's creator about this - https://www.youtube.com/watch?v=W7qj_WFClls). It's quite slow though. `NO_CONTRACTS=true` will turn off the system and speed up building. It's [recommended in the middleman docs](https://middlemanapp.com/basics/build-and-deploy). ``` $ time bundle exec middleman build real 1m9.209s user 4m55.782s sys 0m51.051s ``` ``` $ time NO_CONTRACTS=true bundle exec middleman build real 0m58.144s user 4m3.325s sys 0m46.966s ```
1 parent 9b93072 commit 4b624a7

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export GITHUB_TOKEN=somethingsomething
5858
Build the site with:
5959

6060
```
61-
bundle exec middleman build
61+
NO_CONTRACTS=true bundle exec middleman build
6262
```
6363

6464
This will create a bunch of static files in `/build`.

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
namespace :assets do
1919
task :precompile do
20-
sh 'git clone https://github.com/alphagov/govuk-content-schemas.git /tmp/govuk-content-schemas --depth=1 && GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas middleman build'
20+
sh 'git clone https://github.com/alphagov/govuk-content-schemas.git /tmp/govuk-content-schemas --depth=1 && NO_CONTRACTS=true GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas middleman build'
2121
end
2222
end
2323

bin/deploy-to-s3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ git clone https://github.com/alphagov/govuk-content-schemas.git /tmp/govuk-conte
77
export GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas
88

99
bundle install --path "${HOME}/bundles/${JOB_NAME}" --deployment
10-
bundle exec middleman build --verbose
10+
NO_CONTRACTS=true bundle exec middleman build --verbose
1111
s3cmd sync -v --acl-public --guess-mime-type --add-header='Cache-Control: max-age=3600, public' --delete-removed build/ s3://govuk-developer-documentation-production/

startup.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
bundle exec middleman server
1+
#!/bin/bash -x
2+
3+
set -eu
4+
5+
bundle check || bundle install
6+
NO_CONTRACTS=true bundle exec middleman server

0 commit comments

Comments
 (0)