NodeJS app + postgress without PG clusters

Hello!

We’ve been looking into Fly.io for a while because we’re thinking that it might be a good match for us in order to speed up the process for our clients and such.
Currently, we’re using DigitalOcean for our setups, and while we use Managed DB for some projects that require it; we still have small projects where the client is possibly just a friend or a really small business and they only need a site and some simple CMS to manage the content. So having managed database might be too much, and so we set up a simple DB in the same Droplet.

So that is basically what I would like to ask, for setups where the DB will be small and we don’t really care about scalability and things like that, is it possible to have the Postgress DB within the VM instance?

Thank you very much!

Hi @Bernat_Jufre_Martine! Yes, this should be possible. The important thing here would be that you’ll want to attach a volume (see Volumes). You can then install and start the database (or just use SQLite) in your Dockerfile.

You can then use a process manager (see Running Multiple Processes Inside A Fly.io App) to keep your app server and DB running together.

This will restrict you to the region where your volume is created, and you’ll only have a single instance running at any time, but I do that for blogs and other small sites and find it works ok.

2 Likes

You can definitely do what you’re asking, but if it were me I’d have one shared cluster for multiple clients. Clusters can have multiple databases, and fly pg attach will create a new DB with a unique user.

3 Likes

@Bernat_Jufre_Martine - you can learn more on the attach command here: Reset Fly Postgres credentials / detach / attach. - #4 by dan.wetherald