Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake command after deploy on Dokku

I'm running a RoR application with dokku on production.

What is the simplest way to automate and run a rake to clear my cache after every deploy?

like image 835
maiconsanson Avatar asked Feb 12 '26 18:02

maiconsanson


1 Answers

For now I solved using a deploy hook plugin for Dokku: https://github.com/mlomnicki/dokku-deploy-hooks

With the installed plugin, create a file named "deploy/post-deploy" in the root of app. Inside this file just use the rake previously created.

rake file:

# lib/tasks/clear-cache.rake

namespace :cache do
  desc 'Clear all Cache'
  task clear: :environment do
    Rails.cache.clear
    puts "=========== > ALL CACHES WERE GONE!"
  end
end

post-deploy file:

# deploy/post-deploy

rake cache:clear

Now on every deploy the rake will be executed:

web| [12] * Preloading application
worker| Cache clear: flushing all keys
worker| Dalli::Server#connect
worker| =========== > ALL CACHES WERE GONE!
web| [12] * Listening on tcp://0.0.0.0:5000
like image 167
maiconsanson Avatar answered Feb 15 '26 11:02

maiconsanson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!