Jets supports Rails and allows you to run it on AWS Lambda with little effort. You simply run an import command, test, and deploy. Here’s a Blog Post Tutorial: Jets Mega Mode: Run Rails on AWS Lambda. Below is an additional introduction and example:
Mega Mode can be set up with the
jets import command. Here’s an example of importing a Rails application and setting it up with Mega Mode.
cd demo # demo is jets app jets import:rails http://github.com/tongueroo/demo-rails.git
This essentially copies the project to a rack folder within the demo jets app. The import command also adds an example route to
config/routes.rb to enable mega mode. It looks something like this:
Jets.application.routes.draw do # ... # any "*catchall", to: "jets/public#show" # commented out by jets import # enables Mega Mode integration any "*catchall", to: "jets/rack#process" end
The added catchall route maps to a special
jets/rack_controller which forwards requests from the main jets app to the sub rails app in the
rack folder. This allows you to selectively route urls to the rails or the jets app, depending on your needs.
Testing Rack App Locally
jets server command automatically starts the sub-rack application server up for you. Example:
jets server # starts both jets and rack servers up
The jets server runs on port 8888 and the rack server runs on port 9292.
If you would like to test the rack application without jets directly you can always start up the rack app directly.
cd demo/rack # go into the rack project folder directly bundle # install dependencies rackup # start up the rack app directly
Starting up the rack app directly is a good way to test it independently.
When you’re ready to deploy, run:
Additional Import Examples
The import command understands a variety of values. Examples:
jets import:rails tongueroo/demo-rails # expands to github jets import:rails firstname.lastname@example.org:tongueroo/demo-rails.git jets import:rails /path/to/folder/demo-rails
Rails Versions Supported
Jets Mega Mode has been tested and works Rails 4 and above.
Currently MySQL and PostgreSQL are supported via ActiveRecord. You will have to configure your Rails app with a version of the database adapter that is supported by Jets. This is usually done with the Gemfile and the
Pro tip: Use the <- and -> arrow keys to move back and forward.