Skip to content

Adding initial Supabase support #722

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

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

MarioGK
Copy link

@MarioGK MarioGK commented Jun 9, 2025

…figuration options

**Closes #417 **

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package (4000 total character limit, so don't push entire description over that)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

This is just an initial and highly work in progress as Supabase has so many container dependecies and environments to set to make everything work together.

@MarioGK MarioGK changed the title Adding intial Supabase support Adding initial Supabase support Jun 9, 2025
MarioGK added 3 commits June 9, 2025 11:43
…ent variables for Studio, Realtime, Storage, Meta, Image Proxy, Logflare, and Edge Runtime services
Copy link
Member

Choose a reason for hiding this comment

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

I assume the commented out tests are there to remind you of API coverage to tackle

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's correct

Comment on lines 139 to 141
.WithDbContext<MyDbContext>((sp, options) =>
options.UseNpgsql(
supabase.ConnectionStringExpression.GetValueAsync().Result));
Copy link
Contributor

Choose a reason for hiding this comment

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

??? Why is this in the hosting integration, this isn't what any other database does. Also Task.Result....no please

Copy link
Author

Choose a reason for hiding this comment

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

This was just AI slop when i asked it to reformat the README.md to a more readable markdown i will do a proof read when i convert from draft to a normal PR.
Thanks catching it

Comment on lines 28 to 29
int? apiPort = 8080,
int? dbPort = null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Leave these out and add methods

Copy link
Contributor

Choose a reason for hiding this comment

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

Dont hardcode host ports

Copy link
Author

Choose a reason for hiding this comment

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

Will do, this is a WIP PR, there are many things that are temporary, but i imagine i will fix a lot of them today.

MarioGK added 2 commits June 11, 2025 10:22
…nce password management.

Always add Postgres, Kong and Studio with AddSupabase as they are kind of necessary and removes boilerplate.
@MarioGK
Copy link
Author

MarioGK commented Jun 11, 2025

I added postgres, kong and studio to the Supbase resource as they are kinda of mandatory to have a working supabase experience.(i might add logflare as a default resource as well in the future)
There are tons of stuff to fix regarding ports and etc.

@MarioGK
Copy link
Author

MarioGK commented Jun 11, 2025

One feedback that i would like @aaronpowell or @davidfowl if you could help me out with your opinion.
Should i keep using a single resource AKA SupabaseResource to all configuration and parameters like i am using now or should i create a resource for each container?
For example should i create SupabasePostgresResource class and have the ConnectionString there?

MarioGK added 3 commits June 11, 2025 12:02
… and enhance parameter management for database and dashboard credentials.
…variables for endpoints and enhance modularity.
Copy link
Member

@Alirexaa Alirexaa left a comment

Choose a reason for hiding this comment

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

@MarioGK, I left some nit-pick comments.

I have some thoughts about the public API shape.
I don't like AddAllSupabase or WithAll. These methods can not describe the resource and do not expose an appropriate API to mutate the resource.

Each module should add to the application model by calling WithXXX method and each of these methods should expose a configureContainer param to expose ability to mutate resource like adding an environment variable or changing the host port.

Look at WithDbGate for instance:

public static IResourceBuilder<PostgresServerResource> WithDbGate(this IResourceBuilder<PostgresServerResource> builder, Action<IResourceBuilder<DbGateContainerResource>>? configureContainer = null, string? containerName = null)

This is what I like:

builder.AddSupabase("supabase")
    .WithKong(c=> 
      {
            c.WithHostPort(32525); // configure kong host port
            c.WithDataVolume(); // configure kong container volume
      })
      .WithRest(c=> 
        {
        // configure rest resource here
        });

So you should create Resource per container and expose IResourceBuilder<TResource> for that resource in the WithXXX method.

Also it's good to expose WithDataVolume, WithDataBindMount and WithHostPort for each resource.

This is another example. Here RedisInsight is sub resource of Redis and we can configure the RedisInsight host port and data volume.

https://github.com/dotnet/aspire/blob/9c4e360642af6fa9a8d6566a7747a5b1e35f3500/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs#L385-L411

https://github.com/dotnet/aspire/blob/9c4e360642af6fa9a8d6566a7747a5b1e35f3500/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs#L278-L292

Comment on lines +6 to +8
<DefaultTargetFramework>net9.0</DefaultTargetFramework>
<TargetFrameworks>$(DefaultTargetFramework)</TargetFrameworks>
<AllTargetFrameworks>$(DefaultTargetFramework);net9.0</AllTargetFrameworks>
<AllTargetFrameworks>$(DefaultTargetFramework);net8.0</AllTargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Author

Choose a reason for hiding this comment

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

I was having some problems running in my machine, will rollback it before converting from draft.
Dont know why net8 was not being recognized correctly

MarioGK and others added 2 commits June 11, 2025 17:04
…dling and enhance logging during database creation.
Co-authored-by: Alireza Baloochi  <alireza.baloochi1380@gmail.com>
@MarioGK
Copy link
Author

MarioGK commented Jun 11, 2025

@MarioGK, I left some nit-pick comments.

I have some thoughts about the public API shape. I don't like AddAllSupabase or WithAll. These methods can not describe the resource and do not expose an appropriate API to mutate the resource.

Each module should add to the application model by calling WithXXX method and each of these methods should expose a configureContainer param to expose ability to mutate resource like adding an environment variable or changing the host port.

Look at WithDbGate for instance:

public static IResourceBuilder<PostgresServerResource> WithDbGate(this IResourceBuilder<PostgresServerResource> builder, Action<IResourceBuilder<DbGateContainerResource>>? configureContainer = null, string? containerName = null)

This is what I like:

builder.AddSupabase("supabase")
    .WithKong(c=> 
      {
            c.WithHostPort(32525); // configure kong host port
            c.WithDataVolume(); // configure kong container volume
      })
      .WithRest(c=> 
        {
        // configure rest resource here
        });

So you should create Resource per container and expose IResourceBuilder<TResource> for that resource in the WithXXX method.

Also it's good to expose WithDataVolume, WithDataBindMount and WithHostPort for each resource.

This is another example. Here RedisInsight is sub resource of Redis and we can configure the RedisInsight host port and data volume.

dotnet/aspire@9c4e360/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs#L385-L411

dotnet/aspire@9c4e360/src/Aspire.Hosting.Redis/RedisBuilderExtensions.cs#L278-L292

I agree, it makes more sense this way and being more declarative and more explicit as well.

Just to add the default AddSupabase will setup the following services/modules as they are required for the basic functions of the Studio(AKA the dashboard) to work properly:

AddSupabase() will setup:

  • MetaResource(the parent)
  • Postgres
  • Kong
  • Meta(i think it is a proxy that supabase use to call sql from the studio instead of directly calling the postgres)
  • Logflare

The modules that are going to be optional are:

  • Rest(Postgrest) this might be necesary for the Supabase client so i might add it by default as well
  • Realtime
  • Storage (With an option to configure minio or another s3 server)
  • Auth
  • Edge Runtime

@aaronpowell aaronpowell added the awaiting response Waiting for the author of the issue to provide more information or answer a question label Jun 20, 2025
@aaronpowell aaronpowell reopened this Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response Waiting for the author of the issue to provide more information or answer a question
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Add Supabase integration
4 participants