How to deploy Rails 5.1.2 and Yarn on Dokku

Some real yarn 😊

Last week I deployed a new custom deployment of Airstrip on a Microsoft Azure cloud of one of our clients. For this deployment, I used the new Rails 5.1.2 that uses Yarn to deploy JavaScript and CSS assets.

We use Intercity and Dokku to deploy our apps and deploying Rails 5.1.2 on Dokku is a little different if when you use the new Yarn system to install your assets.

Here’s what you need to do to deploy Rails 5.1.2 on Dokku.

Define custom buildpacks

For both Yarn and Rails to be deployed, you’ll need to use two custom buildpacks for your repository, instead of the standard that Dokku selects on build time. Add these two lines to a (new) .buildpacks file in your repository and push to your Dokku deployment:

# contents of .buildpacks
https://github.com/heroku/heroku-buildpack-nodejs.git#v87
https://github.com/heroku/heroku-buildpack-ruby.git#v142

That’s it!

Git push to your repository on your Dokku-enabled server and you’ll now see your app deploy as expected, including your assets managed via Yarn.

https://github.com/heroku/heroku-buildpack-ruby.git#v142