writeFileToContainer function

Future<void> writeFileToContainer(
  1. String name,
  2. String remotePath,
  3. String content
)

Implementation

Future<void> writeFileToContainer(
  String name,
  String remotePath,
  String content,
) async {
  // Write to a temp file, then docker cp
  final tmpFile = File('/tmp/openci-tmp-${const Uuid().v4()}');
  await tmpFile.writeAsString(content);
  try {
    await copyToContainer(name, tmpFile.path, remotePath);
  } finally {
    try {
      await tmpFile.delete();
    } catch (_) {}
  }
}