Important: LiteFS is outside our scope of support. We are not able to provide support or guidance for it. Use with caution.
Problem
If youāre porting an app from Deno Deploy to Fly.io, you may hit a bit of a snag: if it was built with Deno KV, a traditionally FoundationDB backed K/V store made for Deno Deploy, thereās no obvious way to easily run Deno KV at scale on Fly.io. You could use denoland/denokv on Fly.io, but due to an alignment of the stars there happens to be an easier way. Deno KV can actually be backed by an SQLite DB stored on disk in a cache folder, and you can specify the path of this DB with the parameter toDeno.openKv( <here> ).
This means you can do something like this to get Deno KV to use an arbitrary SQLite DB:
Setting up LiteFS
Firstly, you need to add alitefs.yml file to your project, and make sure it gets included in the Dockerfile.
Hereās an example:
Itās not immediately clear based on the example config, but your app needs to listen on ātargetā (:8081) and your service/http_service in fly.toml needs to listen on āaddrā (:8080). This is because part of LiteFS acts as a proxy, so you need the fly-proxy to send requests to LiteFS which then forwards them on to your app.If youāre not able to change your applicationās port, make sure
target is set up correctly then change addr and fly.toml to something other than :8080.DB_LOCATION is set to /litefs/my.db in fly.toml under [env].
Now, if youāre deploying to Fly.io, youāre almost ready to go. Hereās where to look if youāre not running on Fly.io.
Creating a LiteFS Cloud cluster
For a more in-depth article, check out Getting Started with LiteFS on Fly.io. Head over to the LiteFS section of the dashboard and create a cluster, make a note of the auth token (youāll need it later).Dockerfile
You need to add the dependencies for LiteFS to your Dockerfile:ENTRYPOINT/CMD:
fly.toml to mount the LiteFS volume: