public override async Task <(string hash, string installDir)> GetInstalledSdkDir(SdkInfo sdk) { var(hash, installDir) = await base.GetInstalledSdkDir(sdk); using var _ = await archiveRecorder.tarLock.LockAsync(); if (!archiveRecorder.recordedSdks.Contains(hash)) { await ArchiveUtil.AddDirToTar(archiveRecorder.tarStream, SdkPath(hash), Path.GetFullPath(Path.Combine(installDir, ".."))); archiveRecorder.recordedSdks.Add(hash); } return(hash, installDir); }
public static async Task WriteBuildContext(string directory, string dockerfileContent, Stream stream) { await using var tarStream = new TarOutputStream(stream); var dockerIgnorePath = Path.Combine(directory, ".dockerignore"); Func <string, bool> filter; if (File.Exists(dockerIgnorePath)) { using var ignoreReader = File.OpenText(dockerIgnorePath); filter = await CreateIgnorePredicate(ignoreReader); } else { filter = _ => true; } await ArchiveUtil.AddStringToTar(tarStream, "Dockerfile", dockerfileContent); filter = ExcludeDockerfile(filter); await ArchiveUtil.AddDirToTar(tarStream, "", directory, filter); }
public static async Task <IRecorder> Create(string cacheDir, string sdkDir, string schemaFile, string?currentDir, string sourcesDir, string confDir, string archiveFile) { var stream = File.Create(archiveFile); TarOutputStream tarStream; try { tarStream = new TarOutputStream(stream); try { await ArchiveUtil.AddDirToTar(tarStream, SourcesPath, sourcesDir); } catch { try { await tarStream.DisposeAsync(); } catch {} throw; } } catch { try { await stream.DisposeAsync(); } catch {} throw; } return(new ArchiveRecorder( cacheDir: cacheDir, sdkDir: sdkDir, schemaFile: schemaFile, currentDir: currentDir, sourcesDir: sourcesDir, confDir: confDir, tarDataStream: stream, tarStream: tarStream )); }