Create the application
Creating a new Ruby on Rails application is straightforward, and requires only a few files. First, start by installing therails
Gem. This will be used to scaffold out a new Rails application.
rails new
to scaffold out a new application. The contents will be created in the porter-rails-app
folder:
Local testing
Testing that the application will work locally is straightforward. Start by runningbundle install
in the porter-rails-app
directory. This will install your application dependencies.
http://localhost:3000
in your browser to verify the response. You can also run the following curl
command in a new terminal (do not cancel the running rails
server when executing this):
Creating a porter.yaml
While Porter allows folks to configure the services and other configuration for an application in the Porter UI, you can also optionally configure this in a porter.yaml
. The porter.yaml
file format covers both the build and run portions of your application’s lifecycle. While it is expansive in nature, the following covers a minimum necessary to get your application deployed.
porter.yaml
In the above example, we configure Rails to listen on all interfaces and the configured port 3000
. Both of these are necessary as otherwise the application will not be routable by Porter outside of it’s container.
Note that anything not specified in the porter.yaml
can be configured in the Porter UI, and you can always add new services for a given application both in the porter.yaml
as well as in the UI at a later date.
Push the application to your Github repository
Before deploying, you’ll need to create a Github Repository and push your code to the newly created repository. This will provide you with the ability to setup a Github Action for deploying the app.Deploying your application to Porter
Now that the application has been created on Github, head over to our documentation on Deploying from a Github Repository to complete the setup of your application on Porter. At the end of that process, your application will be up and running on Porter! To ensure that Rails acts in a production-ready, Cloud-Native fashion, be sure to set the following environment variables on your Rails application in the Porter UI.
.env
Testing your application
After the Rails application has been deployed, you can head over to your configured public url for the deployed application. Assuming an domain ofrails-app-4feee654149e65c0.onporter.run
, hitting the / page will result in the default Rails welcome page.
Now that the application is working, checkout the rest of the Porter documentation to find out more ways to leverage the platform to scale your Ruby on Rails to support your needs on Porter.