buildDockerImage method
Build the server Docker image
Implementation
Future<bool> buildDockerImage() async {
if (!config.createServer) return false;
info('Building Docker image...');
// Copy models to server directory for Docker context. Idempotent:
// delete the previous copy first so a second run does NOT end up with
// `<server>/<models>/<models>/` (cp -r merges-into-existing-dir
// semantics on macOS / GNU coreutils).
if (config.createModels) {
final String modelsPath = p.join(config.outputDir, config.modelsPackageName);
final String targetPath = p.join(serverPath, config.modelsPackageName);
final Directory target = Directory(targetPath);
if (target.existsSync()) {
try {
await target.delete(recursive: true);
} catch (_) {
// Best-effort cleanup; cp -r will overwrite.
}
}
await _runner.run('cp', <String>['-r', modelsPath, targetPath]);
}
final ProcessResult? result = await _runner.runWithRetry(
'docker',
<String>[
'build',
'--platform',
'linux/amd64',
'-t',
config.serverPackageName,
'.',
],
workingDirectory: serverPath,
operationName: 'Docker build',
);
return result != null && result.success;
}