Open-source & hosting as a service

I’m pondering building an open source project with RedwoodJS that follows a business model similar to Discourse’s and Ghost’s: hosting as a service.

To do so, I’m thinking about building a companion closed-source app that takes care of deploying new versions to the Google Cloud infrastructure. GC supports functions and CDN distribution, which should be enough for what I need.

The question that arises on my side is whether it makes sense to reuse functions across users. Unlike a Rails instance, for which it makes sense to have an instance running per user. What I’d have though is a database per user.

In case you see something like that as something feasible, I’m wondering how I could adjust the RedwoodJS functions to choose the database url depending on the domain. I’m thinking I could set up a second database connection to query the URL of the database the function should interact with. However, since the Prisma connection is managed by Redwood, I think it’ll be a bit tricky.

What do you think?

Answering to myself. I realized there’s a db.js file where the prisma database is initialized. I think I could extend that one to do an extra roundtrip to get the database url from another service or database. In case it cannot obtain it, it could fallback to the default DATABASE_URL environment variable.