We have done something similar with injecting the datasource into our applications with our own tool. The same approach could be made just using environment variables, however. So something like this in Application.cfc (very rough, but you get the idea):
function onRequestStart() {
}
private string function _setupInjectedDatasource() {
this.datasources[ dsn ] = {
type : 'MySQL'
, port : getEnvironmentVariable( "DBPORT" )
, host : getEnvironmentVariable( "DBHOST" )
, database : getEnvironmentVariable( "DBNAME" )
, username : getEnvironmentVariable( "DBUSERNAME" )
, password : getEnvironmentVariable( "DBPASSWORD" )
, custom : {
characterEncoding : "UTF-8"
, useUnicode : true
}
};
}
private string function _getEnvironmentVariable( required string variableName ) output=false {
var result = CreateObject("java", "java.lang.System").getenv().get( arguments.variableName );
return IsNull( result ) ? "" : result;
}