1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 07:10:05 +02:00
copilot/scripts/build
2017-05-30 23:54:29 +01:00

46 lines
1.1 KiB
JavaScript
Executable File

#!/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');
const flatten = require('lodash.flatten');
const readPkg = require('read-pkg');
const NAMESPACE = 'quay.io/yldio';
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);
const tags = [`${name}:${CIRCLE_BRANCH}`, `${name}:latest`];
await execa(
'docker',
flatten([
'build',
flatten(tags.map(name => ['-t', `${NAMESPACE}/${name}`])),
'-f',
dockerfile,
'.'
]),
{
stdio: 'inherit'
}
);
return execa('docker', ['push', `${NAMESPACE}/${name}`], {
stdio: 'inherit'
});
});
};
main(build());