Skip to main content
While Rails applications on Fly.io normally run on Postgres databases, you can choose to run them on sqlite3. To make this work, you will need to place your databases on persistent Volumes as your deployment image will get overwritten the next time you deploy. Volumes are limited to one host, this currently means that fly.io hosted Rails applications that use sqlite3 for their database can’t be deployed to multiple regions. But if you are okay using beta software, LiteFS could work for multi-region sync, check it out! But this guide assumes you have one node and one volume. Following are the steps required to make this work:

Create volume

Replace name with your desired volume name. Only alphanumeric characters and underscores are allowed in names. Optionally, you may specify the size of the volume, in gigabytes, by adding a --size int argument. The default volume size is 3 gigabytes. Now set the following secret, again replacing the name with what you selected:

Mount and Prep for Deployment

Add the following to your fly.toml, once again replacing the name with what you selected, this time in two places:
Next move the dependency on the db:migrate task from the release to server in lib/tasks/fly.rake:
You can also silence warnings about running sqlite3 in production by adding the following line to config/environments/production.rb:

Deploy

These changes can be deployed using fly deploy.