Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ public class DockerRegistryManager
public const string FullyQualifiedBaseImageAspNet = $"{BaseImageSource}/{AspNetBaseImage}:{Net8PreviewImageTag}";
private static string? s_registryContainerId;

private static string SDK_AzureContainerRegistryImage => "dotnetdhmirror-f8bzbjakh8cga6ab.azurecr.io/registry:2";
private static string Docker_HubRegistryImage => "docker.io/library/registry:2";

// TODO: some logic to pivot between this and Docker Hub
private static string RegistryImageToUse => SDK_AzureContainerRegistryImage;


public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
{
using TestLoggerFactory loggerFactory = new(testOutput);

if (!new DockerCli(loggerFactory).IsAvailable()) {
if (!new DockerCli(loggerFactory).IsAvailable())
{
throw new InvalidOperationException("Docker is not available, tests cannot run");
}

Expand All @@ -40,7 +48,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
{
logger.LogInformation("Spawning local registry at '{registry}', attempt #{attempt}.", LocalRegistry, spawnRegistryAttempt);

CommandResult processResult = ContainerCli.RunCommand(testOutput, "--rm", "--publish", "5010:5000", "--detach", "docker.io/library/registry:2").Execute();
CommandResult processResult = ContainerCli.RunCommand(testOutput, "--rm", "--publish", "5010:5000", "--detach", RegistryImageToUse).Execute();

processResult.Should().Pass().And.HaveStdOut();

Expand All @@ -59,7 +67,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
.Execute()
.Should().Pass();

logger.LogInformation("Tagging image '{sourceRepo}/{sourceImage}:{sourceTag}' as '{targetRepo}/{targetImage}:{targetTag}'.",BaseImageSource, RuntimeBaseImage, tag, LocalRegistry, RuntimeBaseImage, tag);
logger.LogInformation("Tagging image '{sourceRepo}/{sourceImage}:{sourceTag}' as '{targetRepo}/{targetImage}:{targetTag}'.", BaseImageSource, RuntimeBaseImage, tag, LocalRegistry, RuntimeBaseImage, tag);
ContainerCli.TagCommand(testOutput, $"{BaseImageSource}/{RuntimeBaseImage}:{tag}", $"{LocalRegistry}/{RuntimeBaseImage}:{tag}")
.Execute()
.Should().Pass();
Expand All @@ -84,7 +92,7 @@ public static void StartAndPopulateDockerRegistry(ITestOutputHelper testOutput)
{
ContainerCli.StopCommand(testOutput, s_registryContainerId).Execute();
}
catch(Exception ex2)
catch (Exception ex2)
{
logger.LogError(ex2, "Failed to stop the registry {id}.", s_registryContainerId);
}
Expand Down
Loading