Replacing the Dockerfile
When you previously ranfly launch you were provided with a Dockerfile
that was used to package your application. This Dockerfile provided
reasonable defaults. One of those defaults was to choose the Puma web server.
This is the same default that Rails provides for new applications.
This Dockerfile can be customized or replaced to meet your needs. This
guide will show you how to replace the Dockerfile with one that chooses
Phusion Passenger. The new Dockerfile will make use of the
phusion/passenger-full image.
To get started, replace your Dockerfile with the following:
Configuring nginx
The Dockerfile above contains threeADD commands. These copy configuration
files to the image. The first two files configure nginx. Place all three files
in a config/fly directory.
We start with config/fly/rails.conf:
config/fly/envvars.conf:
Enabling swap
Seeswap_size_mb for configuring
for deploys.
Deployment
That’s it. As always you deploy your application viafly deploy and
can open it via fly apps open. Everything else remains the same. You
can use your same Postgre database, redis data store, and any other
secrets you may have set.
Both Puma and Passenger are excellent choices for application servers
for your Rails application, so you normally wouldn’t have a need to
replace one with the other. Further configuration likely is required
to unlock specific features of nginx or passenger for your particular
needs. The above is only intended as an initial configuration to
get you started. You have full control over what is installed on your
machine and how both nginx and passenger are configured.
The sky’s the limit on what you can achieve with these instructions!