We have a current application written in grails 3, which we want to deploy for multiple different clients. The application and the database schema is the same for every client, only the data changes.
We don't want to have a single database because then we will need to rewrite sql queries, code will be harder to manage, indexes will get bigger etc.
We come up with 2 results:
Defining multiple datasources. Each time a new client is registered, a new database should be created, and added (by a script probably) to application.yml. The client will login, and then ideally the datasource will be set at a single point of the code. (Which we haven't found yet a way to do it, on documentation it appears that it can be statically defined at each service). That way we will have one compiled application for all clients, with one database per client.
Setting a different environment for each client. That means we will have one compiled application for each client and then use a folder based structure for deployment. (So that clients will use for example myapplication.com/clientid where the compiled application will be). Again a new environment and database should be created each time a new client registers.
The application is a b2b service so we are talking about tens or hundreds of clients.
EDIT
Which one of the 2 approaches would be better and why ? We would prefer to have one compiled application as it is easier to manage the deployment, but it doesn't seem to be feasible with grails to define dynamically a datasource based on the user logged in (Feel free to coreect me on that if i'm wrong). Thus it's important to have a structure of myapplication.com/clientid, which probably is easier to manage with different environments.