Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

Commit

Permalink
[close heroku#797] Do not carry asset pipeline fragment cache into ru…
Browse files Browse the repository at this point in the history
…ntime

When someone is using the asset pipeline, and they've disabled the config that allows them to build assets in production.

So when

```
config.assets.compile = false
```

Then the `tmp/cache/assets/sprockets/` folder is not needed at runtime and should be safe to delete, which will lower the overall slug size.

Do not merge until after Dreamforce.
  • Loading branch information
schneems committed Oct 23, 2018
1 parent c61a164 commit cbf5893
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Master

* Delete the sprockets temp directory for a smaller runtime slug if they are not building assets at runtime (https://github.com/heroku/heroku-buildpack-ruby/pull/812)

## v195 (10/18/2018)

* Default Ruby version is now 2.4.5 (https://github.com/heroku/heroku-buildpack-ruby/pull/821)
Expand Down
3 changes: 3 additions & 0 deletions hatchet.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
"sharpstone/active_storage_local",
"sharpstone/sprockets_asset_compile_true"
],
"heroku": [
"heroku/ruby-getting-started"
],
"multibuildpack": [
"sharpstone/node_multi"
],
Expand Down
2 changes: 2 additions & 0 deletions hatchet.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
- 540ec776eff3111ad9bb01af204c62725c94a11d
- - "./repos/ci/ruby_no_rails_test"
- 3916137106d59b008b67d738abe6a1438f8fbde6
- - "./repos/heroku/ruby-getting-started"
- 7abd8af85c7ba6486bb03a4964da9cea98766b06
- - "./repos/jruby/jruby_naether"
- c5081c07de64dcd4b480923e4b7e2a98a9b4a431
- - "./repos/multibuildpack/node_multi"
Expand Down
5 changes: 5 additions & 0 deletions lib/language_pack/rails4.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def default_assets_cache
"tmp/cache/assets"
end

def cleanup
super
FileUtils.remove_dir(default_assets_cache) unless assets_compile_enabled?
end

def run_assets_precompile_rake_task
instrument "rails4.run_assets_precompile_rake_task" do
log("assets_precompile") do
Expand Down
4 changes: 4 additions & 0 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ def compile
end
config_detect
best_practice_warnings
cleanup
super
end
end

def cleanup
end

def config_detect
end

Expand Down
9 changes: 9 additions & 0 deletions spec/hatchet/getting_started_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative '../spec_helper'

describe "Heroku ruby getting started" do
it "clears runtime cache" do
Hatchet::Runner.new("ruby-getting-started").deploy do |app|
expect(app.run("ls tmp/cache/assets")).to_not match("sprockets")
end
end
end

0 comments on commit cbf5893

Please sign in to comment.