Deploy Rails 5.1 app with Webpack, React Puma and other

Recently I’ve been working on my inchef-app on localhost, app is almost done, but it was working only on my localhost. My previous projects I was running with unicorn and simple rails and jquery – nothing fancy. So I had my configuration up and running – just needed copy paste, change paths and that it. When yyou play with something new, and dont have any experienced friend around – you have to dive into ocean by your own – and I hate it, so deoploying I postponed as long I could… I like when I have time to focus, and read, play, find exact solution which will fit and will work. So today – Monday – this was good time. I’ve spent bunch of hours to test and check. So my server is running on debian wheezy, old one but good ;), first problem was that webpacker needs to run node > 4.x and I had 0.12 or sth. So simple apt-get install node didn’t worked, because node doesn’t support wheezy ;(. So what I did – I’ve installed node 5.x, than installed npm and than upgraded node to version 8.x 馃槈

than install or use npm

To upgrade to latest version (and not current stable) version, you can use

To undo:

found here:

then I needed yarn:


Ok, so we have lastest node, npm

npm -v # => 5.0.0

node -v #=> v8.0.0

Now we need deploy our app:

Assuming that we are in app directory, we need:

webpack config in config/webpacker.yml

Puma config in config/puma_production.rb

Next I had to run npm install to install needed js libs
Now precompile assets and webpack according to it should be done automatically with rails assets:precompile however this didn’t work – maybe due to missing file config/webpacer.yml. So I executed `bundle exec rails webpacker:compile and it did work 馃槈

Next step… I was able to run puma server from app directory puma -C config/puma.rb and it worked, now we need configure nginx to talk to puma, everyone uses sockets to we also will use socket, my very simple nginx configuration looks like:

I use init.d so had to download proper scripts from




Managing the jungle

Puma apps are held in /etc/puma.conf by default. It’s mainly a CSV file and every line represents one app. Here’s the syntax:

You can add an instance by editing the file or running the following command:

The config and log paths, as well as the environment variables, are optional parameters and default to:

  • config: /path/to/app/config/puma.rb
  • log: /path/to/app/log/puma.log
  • environment: (empty)

Multiple environment variables need to be separated by a semicolon, e.g.

To remove an app, simply delete the line from the config file or run:

The command will make sure the Puma instance stops before removing it from the jungle.

Of course there was a problem with nginx… with my configuration, so very helpful was nginx -t
it will show you cause of the problem.

OK, now I can run sudo service puma start and it will start my apps… and that its few hours of solving problems, now I have my app up and running globally not only on my localhost ;D

Rafath Khan

Rafath Khan - Problem Solver - nie ma czego艣 takiego jak problem, s膮 wyzwania. Od 1998 zwi膮zany z Internetem, programista, projektant, tw贸rca serwis贸w i aplikacji internetowych,, Masz problem? Pomog臋 CI go rozwi膮za膰.

Mo偶e Ci si臋 r贸wnie偶 spodoba