Skip to content

- IdentityServer4, Admin, Admin.Api, STS.Identity, added support for environment-specific configuration files #551

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
Apr 18, 2020
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions src/Skoruba.IdentityServer4.Admin.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ private static IConfiguration GetConfiguration(string[] args)
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this line ? I think apps already works with appsettings{environemnt}.json by default.

Copy link
Contributor Author

@ViRuSTriNiTy ViRuSTriNiTy Mar 25, 2020

Choose a reason for hiding this comment

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

Imho yes, this line is necessary as there is no "automagic" going on here, see #549 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need this line. If anyone wants a custom serilog configuration. The configuration should be mounted into the application.

Define in your release pipeline to mount the serilog.json from the outside to the inside. The proposed line will not work with docker and kubernetes

Copy link
Contributor Author

@ViRuSTriNiTy ViRuSTriNiTy Apr 13, 2020

Choose a reason for hiding this comment

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

I don't think we need this line. If anyone wants a custom serilog configuration. The configuration should be mounted into the application.

Define in your release pipeline to mount the serilog.json from the outside to the inside. The proposed line will not work with docker and kubernetes

Thanks for your feedback but i don't understand your instructions. What does "mounted into the application" actually mean and what "release pipeline"? Do you mean i should copy serilog.Development.json to serilog.json before releasing the application? And why is the proposed solution not working with docker and kubernetes?

Copy link
Contributor

Choose a reason for hiding this comment

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

if you look at the docker compose below
https://github.com/skoruba/IdentityServer4.Admin/blob/master/docker-compose.yml#L35

This give the flexibility for anyone to define serilog.json as they want and mount it from the host machine to the container

Copy link
Contributor

Choose a reason for hiding this comment

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

To me it is not necessary but if you want I'd say if you still want to do it. do it in your fork

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So you want only "necessary" changes not improvements, that's sad as my approach also allows config transformations via SlowCheetah, all effort in vain. Closing the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not the owner of the repo. I just gave a comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

The owner can very well decide to approve your pr

Copy link
Contributor

Choose a reason for hiding this comment

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

.AddJsonFile("serilog.json", optional: true, reloadOnChange: true)
.AddJsonFile($"serilog.{environment}.json", optional: true, reloadOnChange: true);

if (isDevelopment)
{
Expand All @@ -57,7 +59,11 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
{
configApp.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);

if (hostContext.HostingEnvironment.IsDevelopment())
var env = hostContext.HostingEnvironment;

configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
configApp.AddUserSecrets<Startup>();
}
Expand Down
12 changes: 10 additions & 2 deletions src/Skoruba.IdentityServer4.Admin/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private static IConfiguration GetConfiguration(string[] args)
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really need this line ? I think apps already works with appsettings{environemnt}.json by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

.AddJsonFile("serilog.json", optional: true, reloadOnChange: true)
.AddJsonFile($"serilog.{environment}.json", optional: true, reloadOnChange: true);

if (isDevelopment)
{
Expand All @@ -82,7 +84,13 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
configApp.AddJsonFile("identitydata.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile("identityserverdata.json", optional: true, reloadOnChange: true);

if (hostContext.HostingEnvironment.IsDevelopment())
var env = hostContext.HostingEnvironment;

configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile($"identitydata.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
configApp.AddJsonFile($"identityserverdata.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
configApp.AddUserSecrets<Startup>();
}
Expand Down
10 changes: 8 additions & 2 deletions src/Skoruba.IdentityServer4.STS.Identity/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ private static IConfiguration GetConfiguration(string[] args)
var configurationBuilder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);
.AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.AddJsonFile("serilog.json", optional: true, reloadOnChange: true)
.AddJsonFile($"serilog.{environment}.json", optional: true, reloadOnChange: true);

if (isDevelopment)
{
Expand All @@ -57,7 +59,11 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
{
configApp.AddJsonFile("serilog.json", optional: true, reloadOnChange: true);

if (hostContext.HostingEnvironment.IsDevelopment())
var env = hostContext.HostingEnvironment;

configApp.AddJsonFile($"serilog.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);

if (env.IsDevelopment())
{
configApp.AddUserSecrets<Startup>();
}
Expand Down