the DB host, port, user, password and DB can be hardcoded only as of now.
would like for these data points to be allowed to select from ENV variables.
we do not want to set it up via target coz those targets are still visible to all devs who have access to the git repo - if it is part of ENV variables, then we can secure the access of credentials to only those who have access to PROD environment, not all devs. working a team and large projects makes this imperative for us!
we tried to replace these values with {{$_ENV.var_name}} directly in the JSON file for DB conn. that works as expected actually at run time.
however, it breaks Wappler UI itself - we can no longer work with queries/steps that connect with DB to show the list of tables and schema of those tables.
would like for this to work without breaking Wappler!
if selecting from ENV is allowed on DB Conn Options natively within Wappler, it’ll be very convenient. we do not wish to hack our way through setting this up and taking care with each deployment.
I think the last time we were trying this, we did something wrong.
This time, I took it a bit slow, and identified that JSON with connection string for DB Manager is different from the connection string for Globals DB Connection.
All I needed was to play around with the Globals JSON.
Keeping the DB Manager values unchanged, I can connect to dynamic DB based on ENV.
When developing on local, I can still access all query builder UIs.
In my case, I had to get a bit creative with putting a complete JSON in ENV, but as a concept, what you have suggested works.
There is one bug here, in addition to what Nishkarsh has asked for -
Need dynamic picker in UI to select ENV variable instead of having to type.
Port field is restricted to number, so cant bind without going in code view of the JSON file.
To add a little context, we use Caprover for deploying. Which is based on commits.
When using targets in Wappler with DO (or other) Docker setup, everything is handled by target automatically.
But when deploying with Git, the target stuff does not really work well for us.
Now, with ENV setup, everything is in sync.
This is the major reason for this request.
I understand this might not be a concern for majority of Wappler users - but in larger projects where it matters it's a make-or-break situation, hope you can understand the severity of this.
Really hope we can get this sorted soon. Meanwhile, can you guys post a picture of what do I need to change to make the app read from ENV? And do I create a "Production" target?
I made that change on the file you’ve pointed, but when I deploy to Caprover it seems the NodeJS app is reading the file at app/modules/connections/db.json instead of .wappler/targets/Development/app/modules/connections/db.json, as it attempts to find the hostname “db” (as written on app/modules/connections/db.json ) instead of $_ENV[‘DB_HOST’] (as written on .wappler/targets/Development/app/modules/connections/db.json).
Do you have any hints on how to solve this?
P.S.: I’ve created a .env file on my local computer (ignored on Git) , and inserted DB_* variables on Caprover’s dashboard
Thats not caprover. Thats how Wappler works. And its correct.
When you select a target, values from target folder gets copied into the app json file.
So, both dev and prod need to have same config - from ENV.
So, when you commit your code, irrespective of target, what is deployed to Caprover is ENV setup always.
You can fully change the connection properties in the Database Connections within the Server Connect Globals, with dynamic environment variables.
You just have to make sure that the database connection used in the Database Manager is not changed and just points to the direct connection with the right credentials so Wappler can still access your database.
So to resume just change only in Server Connect global database connections and everything should work fine.
not convenient. picker would be desirable. to make it ‘visual’ and convenient.
also, for port, entering text does not work. that field expects numbers only.
on pasting you can see the text, but as soon as focus is lost from the field, it turns back to blank.
better way would be to allow for selection via pickers.