For dotnet 8, it is even easier. In the program.cs just use:
var builder = Host.CreateApplicationBuilder(args);
This adds all preconfigured defaults - more info here: https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.hosting.host.createapplicationbuilder?view=net-9.0-pp#microsoft-extensions-hosting-host-createapplicationbuilder(system-string())
Then you can load/bind options quite easily i.e.
var builder = Host.CreateApplicationBuilder(args);
var services = builder.Services;
var config = builder.Configuration;
services.AddOptions<PostgresConfig>()
.Bind(config.GetSection(PostgresConfig.SectionName));
var postgresConfig = config.GetRequiredSection(PostgresConfig.SectionName).Get<PostgresConfig>();
services.AddDbContextPool<GameStoreContext>(options =>
options.UseNpgsql(postgresConfig.ConnectionString));
var app = builder.Build();
app.Run();