modius
August 4, 2015, 6:20am
1
This seemingly mild mannered commit is full of all kinds of galactic, amazeballs
committed 04:18AM - 15 Jul 15 UTC
Add this to your ./www/farcryConstructor.cfm
:
<cfset THIS.bUseEnv = true>
Then you can configure datasources (and any config) directly via environment variables.
For example, a mySQL database
FARCRY_DSN: "chelsea",
FARCRY_DBTYPE: "mysql",
FARCRY_DSN_CLASS: "org.gjt.mm.mysql.Driver",
FARCRY_DSN_CONNECTIONSTRING: "jdbc:mysql://192.168.33.9:3306/chelsea?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useLegacyDatetimeCode=true",
FARCRY_DSN_USERNAME: "vagrant",
FARCRY_DSN_PASSWORD: "vagrant"
For example, an H2 database
FARCRY_DSN: "chelsea",
FARCRY_DBTYPE: "h2",
FARCRY_DSN_CLASS: "org.h2.Driver",
FARCRY_DSN_CONNECTIONSTRING: "jdbc:h2:chelsea/chelsea;MODE=MySQL",
FARCRY_DSN_USERNAME: "vagrant",
FARCRY_DSN_PASSWORD: "vagrant"
Why do this? Well imagine you are running everything in Docker containers and you want to have your application auto-magically configure itself for the dev or production environments.
2 Likes
modius
August 5, 2015, 12:19am
2
If you have a hankering to see this in action, you should be able to vagrant up
this project and have a sticky beak
If you are interested in Docker containers I've put together a little project that installs Chelsea project in a ready to run Docker container. The whole runs on a local development environment orchestrated by Vagrant.
All made possible by...
The ENV variable support from @justincarter in the latest 7.1.1 release.
The collaborative efforts of the Daemonites working on the Lucee Dockerfiles.
And the pretty stylings of Chelsea Bootstrap theme and sample data.
Enjoy!
For Example, an MSSQL Database
FARCRY_DSN: "my_db_name",
FARCRY_DBTYPE: "mssql2005",
FARCRY_DSN_CLASS: "com.microsoft.jdbc.sqlserver.SQLServerDriver",
FARCRY_DSN_CONNECTIONSTRING: "jdbc:sqlserver://192.168.1.9:1433;DATABASENAME=my_db_name;sendStringParametersAsUnicode=true;SelectMethod=direct",
FARCRY_DSN_USERNAME: "sa",
FARCRY_DSN_PASSWORD: "very_strong_password"
1 Like
modius
February 22, 2016, 5:19am
4
Forgot to mention you can also configure any standard FarCry config in the same way. For example, if you wanted to configure your app’s memcached plugin :
FARCRY_CONFIG_MEMCACHED_SERVERS: "cache:11211"