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:54:29 +03:00
|
|
|
return execa('docker', ['push', `${NAMESPACE}/${name}`], {
|
2017-05-30 21:45:00 +03:00
|
|
|
stdio: 'inherit'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
main(build());
|