buildDockerImage method

Future<bool> buildDockerImage()

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
  if (config.createModels) {
    final String modelsPath = p.join(config.outputDir, config.modelsPackageName);
    final String targetPath = p.join(serverPath, config.modelsPackageName);

    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;
}