Skip to content

Commit

Permalink
Chore: Optimise Heroku deploy (#4754)
Browse files Browse the repository at this point in the history
Because:
- We used caching buildpacks to cache assets and dependencies to speed
up deployments. But they don't make a difference anymore. The Node and
Heroku buildpacks already do a good enough job at caching.
- Yarn install runs twice because we are using both the Node and Ruby
buildpacks - adding a few seconds onto our time to deploy
- We use a slug clean up buildpack to make sure our slug size on heroku
does not grow beyond the 300mb soft limit. With our switch to
Js-bundling for assets, we needed to change the javascript directory
that will be cleaned up.

This commit:
- Remove the .buildcache file as we aren't using the caching buildpacks
its used with anymore.
- Adds `SKIP_YARN_INSTALL` env var to CI, review apps, and the
production environment. This will skip the yarn install task that is
normally automatically invoked by the assets:precompile task.
- Removes the yarn:install override rake task we had for Heroku. It only
seemed to work for Webpacker.
- Amends the slugcleanup and slugignore files to clean up the
appropriate directories after our recent assets overhaul.
  • Loading branch information
KevinMulhern authored Aug 12, 2024
1 parent 6b60715 commit f5501a4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 25 deletions.
5 changes: 0 additions & 5 deletions .buildcache

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: Build assets
env:
RAILS_ENV: test
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SKIP_YARN_INSTALL: true
run: |
bin/rails javascript:build
bin/rails css:build
Expand Down
1 change: 0 additions & 1 deletion .slugcleanup
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
app/javascript
app/assets/javascripts
app/assets/stylesheets
node_modules
tmp
4 changes: 0 additions & 4 deletions .slugignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,3 @@ spec
doc
.github
.rubocop

# Ignore any javascript test files outside of spec/
*.test.js
*.test.jsx
14 changes: 0 additions & 14 deletions lib/tasks/heroku.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,3 @@ namespace :heroku do
Rake::Task['curriculum:content:import'].invoke
end
end

# https://github.com/heroku/heroku-buildpack-ruby/pull/892#issuecomment-640900787
namespace :yarn do
task install: :environment do
# These yarn settings come from the nodejs buildpack
# https://github.com/heroku/heroku-buildpack-nodejs/blob/02af461e42c37e7d10120e94cb1f2fa8508cb2a5/lib/dependencies.sh
yarn_flags = '--production=false --frozen-lockfile --ignore-engines --prefer-offline --cache-folder=~/.cache/yarn'

puts '*** [yarn:install] Configuring yarn with all build dependencies'
command = "yarn install #{yarn_flags}"
puts "Running: #{command}"
system command
end
end

0 comments on commit f5501a4

Please sign in to comment.