Litestack problems with deployment

I’m trying to get a simple Rails app with Litestack deployed, but this part from the blog post doesn’t seem to work:

When the fly launch command is run, Fly.io runs the dockerfile-rails gem, which detects the Litestack gem and configures the Dockerfile with the VOLUME and ENV directives needed to store and access Sqlite databases on persistent volume.

The fly launch command then detects the VOLUME directives from the Dockerfile and adds them to the fly.toml file, which configures a persistent volume on the Fly Machine deployment target.

AFAICS, the only Litestack-specific thing that happens during fly launch is that ENV LITESTACK_DATA_PATH="/data" is added to the Dockerfile, but no “VOLUME and ENV directives needed to store and access Sqlite databases on persistent volume.”

Can anyone help out?

I encountered the same. My dockerfile looks pretty different from the one in the demo repo, and also doesn’t include anything related to LITESTACK_DATA_PATH. I was expecting the database to be persisted after each deploy but, nope!

Anyway, all I can really try at this point is to figure out what parts from the demo’s dockerfile I need to bring over as best as I can :man_shrugging:

I eventually gave up on Litestack, after not getting any answers… :man_shrugging:
Moved to Hetzner and using simple SQLite there without problems.

Hey sorry for the delay! I missed this post. Moving to Hetzner is one way to get it working. If you stick around Fly the fly launch command should detect any VOLUME declarations in a Dockerfile and create a volume in the fly.toml file. If it’s not working that way then there’s a bug.

If you’re doing this with an existing app that’s deployed to Fly you’ll need to setup a volume manually, which you can read more about at Add volume storage · Fly Docs

Thanks for the response Brad!
One thing I’m noticing… Here’s the quote from the blog post describing fly launch:

This will create a fly.toml file in your project working directory environment, and provision resources on Fly.io. A Dockerfile is also generated, which is a description of the server that will be running in production.

But just now you said

the fly launch command should detect any VOLUME declarations in a Dockerfile and create a volume in the fly.toml file

So the post implies that the Dockerfile is generated by the fly launch command, but you’re saying you should already have one by the time you run fly launch. So maybe that’s where the problem lies?

The fly launch command generates a Dockerfile for you with the dockerfile-rails gem at GitHub - fly-apps/dockerfile-rails: Provides a Rails generator to produce Dockerfiles and related files.. You can also run rails g dockerfile if you have that gem installed and it will generate a new Dockerfile for you but Fly will not provision the VOLUME on a deployment (only on launch).

The line that adds the VOLUME directive is at dockerfile-rails/lib/generators/templates/Dockerfile.erb at ec2b18e331ebbdfa1e5331268ba3b7f64b66ccc0 · fly-apps/dockerfile-rails · GitHub, which triggers when the sqlite3 gem is present.

So to sum that up, the “magic” will only work if:

  1. You have a new Rails project with the sqlite3 gem and you’ve run bundle add litestack
  2. You run fly launch, which detects the gems above and generates a Dockerfile with the VOLUME /data directive, provisions a persistent volume at /data on the Fly Machine.

If those conditions aren’t met there’s a few manual steps, mainly adding the VOLUME /data to the Dockerfile and provisioning the volume on that machine.