Skip to content

Allow publishing of Ollama and SQLite hosting integrations #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -51,8 +51,7 @@ public static IResourceBuilder<T> WithOpenWebUI<T>(this IResourceBuilder<T> buil
.WithHttpEndpoint(targetPort: 8080, name: "http")
.WithEnvironment(context => ConfigureOpenWebUIContainer(context, openWebUI))
.WaitFor(builder)
.WithHttpHealthCheck("/health")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave this one in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I've restored the .ExcludeFromManifest() call for the OpenWebUI resource and updated the corresponding test. The change is in commit f29d95f.

.ExcludeFromManifest();
.WithHttpHealthCheck("/health");

configureContainer?.Invoke(resourceBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public static IResourceBuilder<OllamaResource> AddOllama(this IDistributedApplic
return builder.AddResource(resource)
.WithAnnotation(new ContainerImageAnnotation { Image = OllamaContainerImageTags.Image, Tag = OllamaContainerImageTags.Tag, Registry = OllamaContainerImageTags.Registry })
.WithHttpEndpoint(port: port, targetPort: 11434, name: OllamaResource.OllamaEndpointName)
.WithHttpHealthCheck("/")
.ExcludeFromManifest();
.WithHttpHealthCheck("/");
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public static class SqliteResourceBuilderExtensions
/// <param name="databasePath">The optional path to the database file. If no path is provided the database is stored in a temporary location.</param>
/// <param name="databaseFileName">The filename of the database file. Must include extension. If no file name is provided, a randomly generated file name is used.</param>
/// <returns>A resource builder for the Sqlite resource.</returns>
/// <remarks>The Sqlite resource is excluded from the manifest.</remarks>
public static IResourceBuilder<SqliteResource> AddSqlite(this IDistributedApplicationBuilder builder, [ResourceName] string name, string? databasePath = null, string? databaseFileName = null)
{
ArgumentNullException.ThrowIfNull(builder, nameof(builder));
Expand Down Expand Up @@ -56,8 +55,7 @@ public static IResourceBuilder<SqliteResource> AddSqlite(this IDistributedApplic
]
};
return builder.AddResource(resource)
.WithInitialState(state)
.ExcludeFromManifest();
.WithInitialState(state);
}

/// <summary>
Expand All @@ -83,8 +81,7 @@ public static IResourceBuilder<SqliteResource> WithSqliteWeb(this IResourceBuild
.WithBindMount(builder.Resource.DatabasePath, "/data")
.WaitFor(builder)
.WithHttpHealthCheck("/")
.WithParentRelationship(builder.Resource)
.ExcludeFromManifest();
.WithParentRelationship(builder.Resource);

configureContainer?.Invoke(resourceBuilder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ public void OpenWebUIConfigured()
Assert.Single(resource.OllamaResources);
}

[Fact]
public void OpenWebUIResourceIncludedInManifestByDefault()
{
var builder = DistributedApplication.CreateBuilder();
_ = builder.AddOllama("ollama", port: null).WithOpenWebUI();

using var app = builder.Build();

var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();

var resource = Assert.Single(appModel.Resources.OfType<OpenWebUIResource>());

Assert.False(resource.TryGetAnnotationsOfType<ManifestPublishingCallbackAnnotation>(out var annotations));
}

[Fact]
public void OpenWebUIConfiguredWithMultipleOllamaServers()
{
Expand Down Expand Up @@ -383,6 +398,21 @@ public void OllamaRegistersHttpHealthCheck()
Assert.Contains(resource.Name, annotation.Key);
}

[Fact]
public void ResourceIncludedInManifestByDefault()
{
var builder = DistributedApplication.CreateBuilder();
_ = builder.AddOllama("ollama");

using var app = builder.Build();

var appModel = app.Services.GetRequiredService<DistributedApplicationModel>();

var resource = Assert.Single(appModel.Resources.OfType<OllamaResource>());

Assert.False(resource.TryGetAnnotationsOfType<ManifestPublishingCallbackAnnotation>(out var annotations));
}

[Fact]
public void OllamaRegistrationContainsResourceCommandAnnotations()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ public void ResourceIsRunningState()
}

[Fact]
public void ResourceExcludedFromManifestByDefault()
public void ResourceIncludedInManifestByDefault()
{
var builder = DistributedApplication.CreateBuilder();
var sqlite = builder.AddSqlite("sqlite");

Assert.True(sqlite.Resource.TryGetAnnotationsOfType<ManifestPublishingCallbackAnnotation>(out var annotations));
var annotation = Assert.Single(annotations);

Assert.Null(annotation.Callback);
Assert.False(sqlite.Resource.TryGetAnnotationsOfType<ManifestPublishingCallbackAnnotation>(out var annotations));
}

[Fact]
Expand Down Expand Up @@ -145,6 +142,18 @@ public async Task SqliteWebResourceConfigured()
Assert.Equal("sqlite", parentAnnotation.Resource.Name);
}

[Fact]
public void SqliteWebResourceIncludedInManifestByDefault()
{
var builder = DistributedApplication.CreateBuilder();
var sqlite = builder.AddSqlite("sqlite")
.WithSqliteWeb();

var sqliteWeb = Assert.Single(builder.Resources.OfType<SqliteWebResource>());

Assert.False(sqliteWeb.TryGetAnnotationsOfType<ManifestPublishingCallbackAnnotation>(out var annotations));
}

[Fact]
public void ResourceWithExtensionFromNuGet()
{
Expand Down