forked from SoDOff-Project/sodoff
modify production configs to use environment var for db connection
This commit is contained in:
parent
9804c6c1a0
commit
51ead169e8
@ -12,7 +12,6 @@ public class ApiServerConfig {
|
||||
public DbProviders ProdDbProvider { get; set; } = DbProviders.MySQL;
|
||||
public string DbPath { get; set; } = string.Empty;
|
||||
public string DbConnection { get; set; } = string.Empty;
|
||||
public string ProdDbConnection { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public enum DbProviders {
|
||||
|
@ -17,14 +17,14 @@ namespace sodoff.Model
|
||||
#if USE_POSTGRESQL
|
||||
if (config.Value.ProdDbProvider == DbProviders.PostgreSQL)
|
||||
{
|
||||
optionsBuilder.UseNpgsql(config.Value.ProdDbConnection).UseLazyLoadingProxies();
|
||||
optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("PRODUCTION_DB_CONNECTION")).UseLazyLoadingProxies();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#if USE_MYSQL
|
||||
if (config.Value.ProdDbProvider == DbProviders.MySQL)
|
||||
{
|
||||
optionsBuilder.UseMySQL(config.Value.ProdDbConnection).UseLazyLoadingProxies();
|
||||
optionsBuilder.UseMySQL(Environment.GetEnvironmentVariable("PRODUCTION_DB_CONNECTION")).UseLazyLoadingProxies();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@ -72,10 +72,7 @@
|
||||
"// DbConnection": "Database connection string for PostgreSQL and MySQL",
|
||||
"// DbConnection PostgreSQL Example": "Host=127.0.0.1;Database=sodoffdb;Username=sodoffuser;Password=secret",
|
||||
"// DbConnection MySQL Example": "Server=127.0.0.1;Database=sodoffdb;Uid=sodoffuser;Pwd=secret;Allow User Variables=True",
|
||||
"DbConnection": "",
|
||||
|
||||
"// ProdDbConnection": "Database connection string for PostgreSQL and MySQL (examples above)",
|
||||
"ProdDbConnection": "Server=${PRODUCTION_DB_SERVER};Database=sodoffdb;Uid=sodoffuser;Pwd=${PRODUCTION_DB_PASSWORD};Allow User Variables=True"
|
||||
"DbConnection": ""
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user