@@ -4,14 +4,17 @@ public class Program {
4
4
public static void Main ( string [ ] args ) {
5
5
var builder = WebApplication . CreateBuilder ( args ) ;
6
6
7
+ string _secretDir = Environment . GetEnvironmentVariable ( "SPACEFX_SECRET_DIR" ) ?? throw new Exception ( "SPACEFX_SECRET_DIR environment variable not set" ) ;
7
8
// Load the configuration being supplicated by the cluster first
8
- builder . Configuration . AddJsonFile ( Path . Combine ( "{env:SPACEFX_CONFIG_DIR }", "config" , "appsettings.json" ) , optional : true , reloadOnChange : false ) ;
9
+ builder . Configuration . AddJsonFile ( Path . Combine ( $ " { _secretDir } ", "config" , "appsettings.json" ) , optional : false , reloadOnChange : false ) ;
9
10
10
11
// Load any local appsettings incase they're overriding the cluster values
11
12
builder . Configuration . AddJsonFile ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "appsettings.json" ) , optional : true , reloadOnChange : false ) ;
12
13
13
14
// Load any local appsettings incase they're overriding the cluster values
14
- builder . Configuration . AddJsonFile ( Path . Combine ( Directory . GetCurrentDirectory ( ) , "appsettings.{env:DOTNET_ENVIRONMENT}.json" ) , optional : true , reloadOnChange : false ) ;
15
+ string ? dotnet_env = Environment . GetEnvironmentVariable ( "DOTNET_ENVIRONMENT" ) ;
16
+ if ( ! string . IsNullOrWhiteSpace ( dotnet_env ) )
17
+ builder . Configuration . AddJsonFile ( Path . Combine ( Directory . GetCurrentDirectory ( ) , $ "appsettings.{ dotnet_env } .json") , optional : true , reloadOnChange : false ) ;
15
18
16
19
builder . WebHost . ConfigureKestrel ( options => options . ListenAnyIP ( 50051 , o => o . Protocols = HttpProtocols . Http2 ) )
17
20
. ConfigureServices ( ( services ) => {
0 commit comments