Connecting to a litefs cluster from outside of fly.io

Hi everyone. I am deplying an app that is basically read only on a database with daily updates of a few records. I would like to able to have a replica of the database on my local machinehere and make it the primary so i can add the records.

Is this possible? seems like everything happens automagically inside fly by using the in built consul.

Thanks

Dean

You can use a static lease with LiteFS instead of Consul, however, it might be tricky getting your deployed app to connect to your local machine. But if you can get that working with something like ngrok then you could keep the SQLite database on your local machine and your deployed machine could fetch updates from there.

The static lease config on your local computer would look like:

lease:
  type: "static"
  candidate: true
  advertise-url: https://yourgeneratedurl.ngrok.io:20202

and then the deployed node would look like:

lease:
  type: "static"
  candidate: false
  advertise-url: https://yourgeneratedurl.ngrok.io:20202

You’ll need to figure out a way to secure LiteFS though. It assumes you’re running on a private network so there’s no built-in auth. Maybe some kind of ssh port forwarding would work instead?

Excellent, thanks that makes a lot of sense,

I am guessing I could use wireguard to connect to my machine and use that IP?

I will have a play and see what I can do. Will update this if i get it working.

Yeah, wireguard should do the trick. That’s a good idea.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.