Switching to Phusion Passenger not working


I’m trying to switch my Rails app over from using the standard Dockerfile with Puma to use Phusion Passenger. This is because my app relies on Redis but when using Puma and Upstash, the app instance keeps restarting (as described here). I tried using the Redis patch for ActionCable, but it didn’t seem to work.

I followed this guide on how to switch to Phusion, but am getting this error when trying to deploy:

 > [13/15] RUN bundle install:
#16 1.541 Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
#16 1.541 installing your bundle as root will break this application for all non-root
#16 1.541 users on this machine.
#16 1.541 Bundler 2.3.7 is running, but your lockfile was generated with 2.4.14. Installing Bundler 2.4.14 and restarting using that version.
#16 3.311 Fetching gem metadata from https://rubygems.org/.
#16 3.355 Fetching bundler 2.4.14
#16 3.407 Installing bundler 2.4.14
#16 3.826 Don't run Bundler as root. Installing your bundle as root will break this
#16 3.826 application for all non-root users on this machine.
#16 3.971 Your Ruby version is 3.1.2, but your Gemfile specified 2.7.0
Error: failed to fetch an image or build from source: error building: executor failed running [/bin/sh -c bundle install]: exit code: 18

I specified ruby 2.7.0 in my rails.conf file:

server {
    listen 8080;
    server_name www.digitin.bishbashbooked.com;
    root /app/public;

    # The following deploys your Ruby/Python/Node.js/Meteor app on Passenger.

    # Not familiar with Passenger, and used (G)Unicorn/Thin/Puma/pure Node before?
    # Yes, this is all you need to deploy on Passenger! All the reverse proxying,
    # socket setup, process management, etc are all taken care automatically for
    # you! Learn more at https://www.phusionpassenger.com/.
    passenger_enabled on;
    passenger_user app;

    # If this is a Ruby app, specify a Ruby version:
    # For Ruby 3.1
    # passenger_ruby /usr/bin/ruby3.1;
    # For Ruby 3.0
    # passenger_ruby /usr/bin/ruby3.0;
    # For Ruby 2.7
    passenger_ruby /usr/bin/ruby2.7;
    # For Ruby 2.6
    # passenger_ruby /usr/bin/ruby2.6;

    # Nginx has a default limit of 1 MB for request bodies, which also applies
    # to file uploads. The following line enables uploads of up to 50 MB:
    client_max_body_size 50M;

so I’m not sure why I am getting this error. I have the Dockerfile as shown in the guide, and within the config directory of my app I have a fly folder with envvars.conf, mkswap.sh and rails.conf. If anyone could help with this that would be great. Or if there are any better ways of getting Redis to work properly with ActionCable/websockets.

My app is running on v2 machines, if that makes any difference.

What this is saying is that the version of Ruby that you are getting when you specify FROM phusion/passenger-full:2.3.0 is 3.1.2.

That guide is now dated, and I’ve generalized the support so that it can build something that matches your environment.

bundle add dockerfile-rails --optimistic --group development
bin/rails generate dockerfile --passenger

That being said, I’m doubtful that Passenger will solve redis connection issues.

Thanks for the reply, do you know any way that I can keep my Redis/ActionCable connection alive that doesn’t use Passenger?

Last year there were automatic timeouts, but those were lifted. So connections should stay alive, but with networks involved anything is possible.

GitHub - anycable/action-cable-redis-backport will prevent connection failures from taking down your application.

The only other approach I know of is to actually run redis inside the same VM as your application. The downside of this approach is that it limits you to one machine.

Thanks, I’ll try the redis-backport gem and see if that solves the issue.

Since the connection should stay alive it’s more likely an issue on my side than the server cutting it off?

Without a stack traceback, I’d only be guessing.

You were working in September, any idea what has changed?

This is a different app to the one that was working in September. The other app was using ActionCable for instant messaging, this one is using it for a remote control purpose.

Basically, the app is listening for the command to refresh the page. This works for a short time, but if you leave it for an hour or so it loses the websocket connection and you have to manually refresh. The ActionCable/Redis setup is exactly the same between the two apps.