run method
Runs this command.
The return value is wrapped in a Future
if necessary and returned by
CommandRunner.runCommand
.
Implementation
@override
Future<bool> run() async {
final blockLogger = logger.headerBlock('Docker Build');
final String imageName = args['name'];
final rootDir = Directory.current.path;
final endaftDir = Utils.pathFromRoot(KnownPaths.endaft);
final dockerDir = path.relative(endaftDir);
blockLogger.printBlock("🧱 Building $imageName image", inRs);
final dockerArgs = [
'build',
'-q',
'--rm',
'--build-arg',
'SOURCE_PATH=$rootDir',
'-t',
imageName.toLowerCase(),
'-f',
'Dockerfile.al2',
'.'
];
final String pti = ' ';
final result =
await Process.start('docker', dockerArgs, workingDirectory: dockerDir)
.then((p) {
p.stdout.pipe(blockLogger.getPipeOut(pti));
p.stderr.pipe(blockLogger.getPipeErr(pti));
return p;
});
final exitCode = await result.exitCode;
return blockLogger.close(exitCode == 0);
}