joyent-portal/scripts/build

46 lines
1.1 KiB
Plaintext
Raw Normal View History

2017-05-30 21:45:00 +03:00
#!/usr/bin/env node
const execa = require('execa');
const main = require('apr-main');
const map = require('apr-map');
const globby = require('globby');
const path = require('path');
2017-05-31 01:23:43 +03:00
const flatten = require('lodash.flatten');
2017-05-30 21:45:00 +03:00
const readPkg = require('read-pkg');
2017-05-31 01:23:43 +03:00
const NAMESPACE = 'quay.io/yldio';
2017-05-30 21:45:00 +03:00
const ROOT = path.join(__dirname, '..');
const CIRCLE_BRANCH = process.env['CIRCLE_BRANCH'];
const build = async () => {
const dockerfiles = await globby(['packages/*/Dockerfile'], {
cwd: ROOT
});
return map(dockerfiles, async dockerfile => {
const folder = path.resolve(ROOT, path.dirname(dockerfile));
const { name } = await readPkg(folder);
2017-05-31 01:23:43 +03:00
const tags = [`${name}:${CIRCLE_BRANCH}`, `${name}:latest`];
2017-05-30 21:45:00 +03:00
2017-05-31 01:23:43 +03:00
await execa(
'docker',
flatten([
'build',
flatten(tags.map(name => ['-t', `${NAMESPACE}/${name}`])),
'-f',
dockerfile,
'.'
]),
{
stdio: 'inherit'
}
);
2017-05-31 01:40:15 +03:00
return execa('git', ['push', `${NAMESPACE}/${name}`], {
2017-05-30 21:45:00 +03:00
stdio: 'inherit'
});
});
};
main(build());