/// <summary> /// Creates the Dockerfile necessary to package up an ASP.NET Core app if one is not already present at the root /// path of the project. /// </summary> /// <param name="project">The project.</param> /// <param name="stageDirectory">The directory where to save the Dockerfile.</param> public void CopyOrCreateDockerfile(IParsedProject project, string stageDirectory) { string sourceDockerfile = GetProjectDockerfilePath(project); string targetDockerfile = Path.Combine(stageDirectory, DockerfileName); string entryPointName = CommonUtils.GetEntrypointName(stageDirectory) ?? project.Name; string baseImage = string.Format(RuntimeImageFormat, project.FrameworkVersion); if (FileSystem.File.Exists(sourceDockerfile)) { FileSystem.File.Copy(sourceDockerfile, targetDockerfile, overwrite: true); } else { string content = string.Format(DockerfileDefaultContent, baseImage, entryPointName); FileSystem.File.WriteAllText(targetDockerfile, content); } }
/// <summary> /// Creates the Dockerfile necessary to package up an ASP.NET Core app if one is not already present at the root /// path of the project. /// </summary> /// <param name="project">The project.</param> /// <param name="stageDirectory">The directory where to save the Dockerfile.</param> internal static void CopyOrCreateDockerfile(IParsedProject project, string stageDirectory) { var sourceDockerfile = Path.Combine(project.DirectoryPath, DockerfileName); var targetDockerfile = Path.Combine(stageDirectory, DockerfileName); var entryPointName = CommonUtils.GetEntrypointName(stageDirectory) ?? project.Name; var baseImage = s_knownRuntimeImages[project.ProjectType]; if (File.Exists(sourceDockerfile)) { File.Copy(sourceDockerfile, targetDockerfile, overwrite: true); } else { var content = String.Format(DockerfileDefaultContent, baseImage, entryPointName); File.WriteAllText(targetDockerfile, content); } }