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.
This commit is contained in:
Buck Doyle 2016-04-14 10:10:06 +02:00
parent 167bd114c5
commit 6325fa2e8d

65
config/deploy.js Normal file
View File

@ -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);
* }
* });
* });
*
*/
}