chore: create triton profile on deploy script

This commit is contained in:
Sérgio Ramos 2017-05-31 11:32:15 +01:00
parent 14df2c703c
commit e2245dd9c0
2 changed files with 20 additions and 2 deletions

View File

@ -34,8 +34,6 @@ deployment:
- sudo chmod +x /usr/local/bin/docker-compose
# install and setup triton
- yarn global add triton@4.15.0 || cat /home/ubuntu/.yarn-config/global/yarn-error.log
- echo '{"url":"https://eu-ams-1.api.joyent.com", "account":"'$SDC_ACCOUNT'", "keyId":"'$SDC_KEY_ID'", "name":"eu-ams-1", "curr":true}' | triton profile create -f -
- triton env --docker eu-ams-1
development:
branch: master

View File

@ -15,7 +15,27 @@ const NAMESPACE = 'quay.io/yldio';
const ROOT = path.join(__dirname, '..');
const LOG = console.log;
const createTritonProfile = async ({ SDC_ACCOUNT = '', SDC_KEY_ID = '' }) => {
LOG(`${figures.arrowRight} create triton profile SDC_ACCOUNT=${SDC_ACCOUNT.length} SDC_KEY_ID=${SDC_KEY_ID.length}`);
const payload = JSON.stringify({
url: 'https://eu-ams-1.api.joyent.com',
account: SDC_ACCOUNT,
keyId: SDC_KEY_ID,
name: 'eu-ams-1',
curr: true
});
const cp = execa('triton', ['profile', 'create', '-f', '-']);
cp.stdin.write(payload);
return cp;
};
const getEnv = async () => {
await createTritonProfile(process.env);
const tritonEnv = await execa.stdout('triton', ['env']);
const dotEnv = tritonEnv.replace(/^export /gim, '');
return Object.assign({}, process.env, parse(dotEnv));