Wednesday, March 12, 2008

pattern: All Configs Deployment

What
Ship config for every environment with each application.
How
  1. Get your continuous intergration server to build all your applications without tieing them to one environment. Package all configs for each application together with the application.
  2. Write a deployment tool that takes your build artifact for an application and deploys it into an environment.
  3. Either get the deployment tool to select the correct config for that environment or even better, somehow get the environment to select it's own config.
  4. Extend your deployment tool to take your application from any environment and deploy it to a different environment. As all configs travel with the application this is trivial.
Why
Pros
  • You can promote to production from uat without having a seperate build.
  • You can run your prod code in uat safely as it's uat configuration is easily available (without trauling through svn).
  • Your continuous intergration server doesn't have to create a zip of each app for each environment - it zips once per app, keeping a quick build / test cycle.
  • Uses a lot less disk space than separate app / env zips.
Cons
  • Not as easy to just take a raw artifact from cruise and use it.
Q. But wait I here you cry - you can't distribute the prod config to other environments otherwise everyone would see the production passwords / connection string.
A. For sensitive values, have variables in your config that are resolved at runtime by a local environment config file. As this file should not be under version control, it should contain as little config as possible, with the main config being shipped with the app.

2 comments:

MrMattWright said...

One major advantage also (as you know) is that you can 100% gaurantee that the code that has been run in UAT is the _exact_ code that will run in PROD. Now, if only we didn't have to write our own configuration system for this in .NET I would be a happy man. I mean come on Microsoft: 1 app.config to rule them all. Oh, that was so like...2002.

Giles Cope said...

And again - same pattern, different bank.