From 6325fa2e8d7a88f004e00eb4573d97157f1a9ab8 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Thu, 14 Apr 2016 10:10:06 +0200 Subject: [PATCH] Add preliminary deployment configuration This assumes that, for instance, the S3 credentials are available as environment variables. There are some decisions about where to store configuration that need discussion, this is just to get things going for now. --- config/deploy.js | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 config/deploy.js diff --git a/config/deploy.js b/config/deploy.js new file mode 100644 index 00000000..03985026 --- /dev/null +++ b/config/deploy.js @@ -0,0 +1,65 @@ +var VALID_DEPLOY_TARGETS = [ //update these to match what you call your deployment targets + 'dev', + 'qa', + 'prod' +]; + +module.exports = function(deployTarget) { + var ENV = { + build: {}, + redis: { + allowOverwrite: true, + keyPrefix: 'travis:index' + }, + s3: { + prefix: 'travis', + bucket: 'travis-web-production-next', + region: 'eu-west-1' + } + }; + if (VALID_DEPLOY_TARGETS.indexOf(deployTarget) === -1) { + throw new Error('Invalid deployTarget ' + deployTarget); + } + + if (deployTarget === 'dev') { + ENV.build.environment = 'development'; + ENV.redis.url = process.env.REDIS_URL; + ENV.plugins = ['build', 'redis']; // only care about deploying index.html into redis in dev + } + + if (deployTarget === 'qa' || deployTarget === 'prod') { + ENV.build.environment = 'production'; + ENV.s3.accessKeyId = process.env.AWS_KEY; + ENV.s3.secretAccessKey = process.env.AWS_SECRET; + } + + if (deployTarget === 'qa') { + ENV.redis.url = process.env.QA_REDIS_URL; + } + + if (deployTarget === 'prod') { + ENV.redis.url = process.env.REDIS_URL; + } + + return ENV; + + /* Note: a synchronous return is shown above, but ember-cli-deploy + * does support returning a promise, in case you need to get any of + * your configuration asynchronously. e.g. + * + * var Promise = require('ember-cli/lib/ext/promise'); + * return new Promise(function(resolve, reject){ + * var exec = require('child_process').exec; + * var command = 'heroku config:get REDISTOGO_URL --app my-app-' + deployTarget; + * exec(command, function (error, stdout, stderr) { + * ENV.redis.url = stdout.replace(/\n/, '').replace(/\/\/redistogo:/, '//:'); + * if (error) { + * reject(error); + * } else { + * resolve(ENV); + * } + * }); + * }); + * + */ +}