Hello all. I'm working on a lucee migration projec...
# cfml-general
b
Hello all. I'm working on a lucee migration project using docker. One of my tasks is to create the datasources for both prod and dev but, both have to be the same datasource name. (abcdb for example). the databases live on AWS and ideally we would like to have it so if we have the docker container running locally it would point to the dev DB and if it deployed on the server it would use the prod DB. I thought about using an edit to my hosts file but I don't think that will work because the RDS ip's are dynamic. Wondering if anyone had a similar challenge?
b
We do this all the time using the following stack • commandbox (which honestly we normally use outside of Docker locally) • The
ortussolutions/commandbox
docker image • The
commandbox-dotenv
module for reading
.env
files • The
commandbox-cfconfig
module for loading config into Lucee while allowing for easy config replacements Then setup a
.cfconfig.json
file in your site with placeholders for the bits in the DSN that need to change or are sensitive (like passwords). For local dev, just use an
.env
file, and for all other environments use env vars or docker secrets, etc to provide those values.
You can see an example of this in our default ColdBox app template (even though the idea is not specific to ColdBox). We even have a sample dockerfile in there https://github.com/coldbox-templates/default
And on production, pulls from a docker secret called
DB_HOST
b
Thanks Brad I will check that out.
b
You could basically test that repo by running
Copy code
coldbox create app
install
server start
in CommandBox and the site would be up and running with the DSN configured and ready to go
Or, build the docker container and run it and you'd get the same thing
e
Or just have a global var called WHICHINSTANCEAMI, or isProd, whatever the case, the unique value, and all config values are stored in a table, and on application start, the server pulls the config query and finds itself that is either a dev box or a production box. You can then based on that information point your entire environment someplace else dynamically.