No docker mode
This commit is contained in:
parent
b697a4b357
commit
56a56c6c38
|
@ -0,0 +1,7 @@
|
||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="BlueWest-NoDocker" type="CompoundRunConfigurationType">
|
||||||
|
<toRun name="DockerComposeDbOnly" type="ShConfigurationType" />
|
||||||
|
<toRun name="BlueWest.Api: BlueWest.WebApi" type="LaunchSettings" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
|
@ -146,7 +146,7 @@ namespace BlueWest.WebApi
|
||||||
.AddSingleton<EventManager>();
|
.AddSingleton<EventManager>();
|
||||||
|
|
||||||
|
|
||||||
services.AddAuthServerServices( _configuration, _environment);
|
services.AddAuthServerServices( _configuration, _environment, configuration);
|
||||||
services.AddScoped<ExchangeInterface>();
|
services.AddScoped<ExchangeInterface>();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,25 @@ namespace BlueWest.WebApi
|
||||||
{
|
{
|
||||||
private static MySqlServerVersion GetMySqlServerVersion(int major, int minor, int build) => new (new Version(major, minor, build));
|
private static MySqlServerVersion GetMySqlServerVersion(int major, int minor, int build) => new (new Version(major, minor, build));
|
||||||
|
|
||||||
|
private static BlueWestConnectionString GetConnectionString(this IConfigurationRoot configurationRoot)
|
||||||
|
{
|
||||||
|
// Docker / No-Docker
|
||||||
|
var startupMode = configurationRoot["mode"];
|
||||||
|
|
||||||
|
if (startupMode == "docker")
|
||||||
|
{
|
||||||
|
var config = configurationRoot.Get<ConnectionStringDocker>();
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var config = configurationRoot.Get<ConnectionStringNoDocker>();
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get MYSQL Connection String
|
/// Get MYSQL Connection String
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,20 +62,8 @@ namespace BlueWest.WebApi
|
||||||
var sqlVersion = GetMySqlServerVersion(8, 0, 11);
|
var sqlVersion = GetMySqlServerVersion(8, 0, 11);
|
||||||
|
|
||||||
// Docker / No-Docker
|
// Docker / No-Docker
|
||||||
var startupMode = configurationRoot["mode"];
|
|
||||||
|
|
||||||
string mySqlConnectionString = String.Empty;
|
string mySqlConnectionString = configurationRoot.GetConnectionString().MySql;
|
||||||
|
|
||||||
if (startupMode == "docker")
|
|
||||||
{
|
|
||||||
var config = configuration.Get<ConnectionStringDocker>();
|
|
||||||
if(config != null) mySqlConnectionString = config.MySql;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var config = configuration.Get<ConnectionStringNoDocker>();
|
|
||||||
if(config != null) mySqlConnectionString = config.MySql;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mySqlConnectionString == string.Empty)
|
if (mySqlConnectionString == string.Empty)
|
||||||
{
|
{
|
||||||
|
@ -131,12 +138,18 @@ namespace BlueWest.WebApi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IServiceCollection AddAuthServerServices(this IServiceCollection services, IConfiguration configuration , IWebHostEnvironment environment)
|
internal static IServiceCollection AddAuthServerServices(this IServiceCollection services, IConfiguration configuration , IWebHostEnvironment environment, IConfigurationRoot configurationRoot)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var connectionString = configurationRoot.GetConnectionString();
|
||||||
|
|
||||||
|
if (connectionString == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Redis connection string is empty");
|
||||||
|
}
|
||||||
|
|
||||||
services
|
services
|
||||||
.AddSingleton(new RedisConnectionProvider("redis://redisinstance:6379"))
|
.AddSingleton(new RedisConnectionProvider(connectionString.Redis))
|
||||||
.AddScoped<IJwtTokenHandler, JwtTokenHandler>()
|
.AddScoped<IJwtTokenHandler, JwtTokenHandler>()
|
||||||
.AddScoped<IJwtFactory, JwtFactory>()
|
.AddScoped<IJwtFactory, JwtFactory>()
|
||||||
.AddHostedService<SessionDataService>()
|
.AddHostedService<SessionDataService>()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"mode": "docker",
|
"mode": "no-docker",
|
||||||
"database": "sqlite",
|
"database": "sqlite",
|
||||||
"environment": "dev"
|
"environment": "dev"
|
||||||
}
|
}
|
Binary file not shown.
|
@ -1,29 +1,22 @@
|
||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
container_name: BW1_DB_MYSQL
|
container_name: BW1_MYSQL
|
||||||
image: mysql/mysql-server:8.0
|
image: mysql/mysql-server:8.0
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_HOST: db
|
MYSQL_ROOT_HOST: localhost
|
||||||
MYSQL_USER_HOST: db
|
MYSQL_USER_HOST: localhost
|
||||||
MYSQL_ROOT_PASSWORD: dXjw127124dJ
|
MYSQL_ROOT_PASSWORD: dXjw127124dJ
|
||||||
MYSQL_USER: blueuser
|
MYSQL_USER: blueuser
|
||||||
MYSQL_PASSWORD: dXjw127124dJ
|
MYSQL_PASSWORD: dXjw127124dJ
|
||||||
MYSQL_DATABASE: bluedb
|
MYSQL_DATABASE: bluedb
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
volumes:
|
volumes:
|
||||||
- ./docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
|
- ./docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
|
||||||
phpmyadmin:
|
|
||||||
container_name: BW_PHPMYADMIN
|
redisinstance:
|
||||||
image: phpmyadmin/phpmyadmin
|
image: "redislabs/redismod"
|
||||||
ports:
|
|
||||||
- 80:80
|
|
||||||
environment:
|
|
||||||
MYSQL_USERNAME: 'blueuser'
|
|
||||||
MYSQL_ROOT_PASSWORD: 'dXjw127124dJ'
|
|
||||||
# ports:
|
|
||||||
# - "3308:3306"
|
|
||||||
redis:
|
|
||||||
image: "redis:alpine"
|
|
||||||
command: redis-server
|
|
||||||
ports:
|
ports:
|
||||||
- "6379:6379"
|
- "6379:6379"
|
||||||
|
container_name: BW1_REDIS
|
||||||
|
|
Loading…
Reference in New Issue