lucify-deploy-config
v0.1.11
Published
Deploy configuration for Lucify projects
Downloads
10
Readme
Deploy configuration for Lucify environment
This project provides environment-specific default deploy configurations for Lucify projects.
Install
npm install lucify-deploy-config --save-dev
Usage
General
const lucifyDeployConfig = require('lucify-deploy-config');
const env = process.env.NODE_ENV;
const opts = {};
// see configuration for current settings
const config = lucifyDeployConfig(env, opts);
console.log(config.base);
The returned config object has the following keys:
env
: Environment, resolved as follows:- Provided
env
option. LUCIFY_ENV
.NODE_ENV
.- If none of the the tree are defined, defaults to
test
.
- Provided
base
: base configuration object, determined by defaults for current environment and provided options. The object has the following keys:bucket
: Name of S3 bucket to which to publish. These are the default values for defaults environments:test
:lucify-protected
development
:lucify-dev
staging
:lucify-staging
production
:lucify-protected
baseUrl
: Base URL, not including path. These are the default values for default environments:test
:https://protected.lucify.com/
development
:http://dev.lucify.com/
staging
:http://staging.lucify.com/
production
:http://www.lucify.com/
maxAge
: Cache duration for assets that are not entry points. These are the default values for default environments:test
,development
andstaging
:0
production
:3600
publicPath
: Public path, afterbaseUrl
. These are the defaults for default environments:test
,/${project}-${branch}-${commit}/
development
,staging
andproduction
:/
project
: Name of the project. Resolved by default with project-name.url
: Full URL topublicPath
. Defaults to string joined frombaseUrl
andpublicPath
.dest
: Local path topublicPath
. Defaults to one joined from the stringdist
andpublicPath
.branch
: Defaults to current git branch.commit
: Defauls to current git commit.flow
: The Flowdock flow id for posting notifications. If not given, falls back to theFLOW
environment variable.- The following snippet might be helpfulf for finding out the correct id
curl -s -u [user]:[password] https://api.flowdock.com/flows | jq '[.[] | select(.organization.name | test("lucify"; "ix")) | {key: .id, value: {name, org: .organization.name}}] | from_entries'
atomicS3
: Default configuration object for atomic-s3, resolved from thebase
object.flowdockDeployNotify
: Default configuration object for flowdock-deploy-notify, resolved from thebase
object.embedSupport
, Default configuration object for embed-support, resolved from thebase
object.
You can override any of values in the base configuration with the opts
parameter. The example following overrides maxAge
for all environments:
const lucifyDeployConfig = require('lucify-deploy-config');
const env = process.env.NODE_ENV;
const opts = { maxAge: 1000 };
const config = lucifyDeployConfig(env, opts);
console.log(config.base.maxAge); // outputs 1000
You can also pass a function, taking env
as its first parameter.
const lucifyDeployConfig = require('lucify-deploy-config');
const env = process.env.NODE_ENV;
const opts = {
maxAge: function(env) {
if (env == 'test') {
return 100;
}
if (env === 'staging') {
return 200;
}
return;
}
};
const config = lucifyDeployConfig('test', opts);
console.log(config.base.maxAge); // returns 100
const config = lucifyDeployConfig('staging', opts);
console.log(config.base.maxAge); // returns 200
const config = lucifyDeployConfig('production', opts);
console.log(config.base.maxAge); // returns 3600 (default value)
If the function returns undefined
, default value for current environment is returned. This way you can use a function to override only some defaults.
Usage with atomic-s3
Example of atomic-s3.config.js
:
var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().atomicS3;
For the test
environment, this will export the following configuration:
{
path: 'dist',
s3options: {
params: {
Bucket: 'lucify-protected'
},
region: 'eu-west-1'
},
entryPoints: [ '**/*.html', '**/resize.js', '**/embed.js', '*.{png,ico}' ]
}
The project supports providing encrypted aws credentials via the environment variable AWS_CREDENTIALS
. The variable must be a JSON string encrypted with libsodium
using crypto_secretbox_open_easy
. The string should represent a json object with the following fields:
access_key_id
,secret_access_key
,session_token
For decryption to work, you should also define LUCIFY_ENC_NONCE
and LUCIFY_ENC_KEY
. We are using this for (production) deployments triggered from Heaven
.
Usage with embed-support
Example of embed-support.config.js
var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().embedSupport;
For the test
environment, this will export the following configuration:
{
dest: 'dist/[project]-[branch]-[commit]/',
destUrl: 'https://protected.lucify.com/[project]-[branch]-[commit]/',
iframeUrl: 'https://protected.lucify.com/[project]-[branch]-[commit]/'
}
Usage with lucify-notifier
Example of lucify-notifier.config.js
var lucifyDeployConfig = require('lucify-deploy-config').default;
module.exports = lucifyDeployConfig().lucifyNotifier;
This will export the following configuration:
{
deployment: {
branch: {
ref: base.branch,
owner: process.env.CIRCLE_PROJECT_USERNAME || 'lucified',
repository: base.project,
},
committer: process.env.GITHUB_USERNAME || process.env.CIRCLE_USERNAME,
url: base.url,
build_url: process.env.CIRCLE_BUILD_URL,
environment: env,
},
github: {
s3_credentials: 'lucify-configuration/lucify-notifier/github_integration_credentials.json',
deploymentOptions: {
transient_environment: true,
},
},
flowdock: {
flow_token: '',
author: {
email: '[email protected]',
},
},
decryption_key: 's3://lucify-configuration/lucifer/public-key.pem',
}
Test
Make sure you have the correct node version
nvm use
Then run tests with
npm test