From 56a56c6c38531c689ae32f466002d81e48000843 Mon Sep 17 00:00:00 2001
From: Wvader <34067397+wvader@users.noreply.github.com>
Date: Sun, 18 Sep 2022 02:17:37 +0100
Subject: [PATCH] No docker mode
---
.run/BlueWest-NoDocker.run.xml | 7 +++++
BlueWest.Api/Startup.cs | 2 +-
BlueWest.Api/StartupExtensions.cs | 47 +++++++++++++++++++-----------
BlueWest.Api/config.json | 2 +-
data/dump.rdb | Bin 0 -> 1397 bytes
docker-compose.db.only.yml | 25 ++++++----------
6 files changed, 48 insertions(+), 35 deletions(-)
create mode 100644 .run/BlueWest-NoDocker.run.xml
create mode 100644 data/dump.rdb
diff --git a/.run/BlueWest-NoDocker.run.xml b/.run/BlueWest-NoDocker.run.xml
new file mode 100644
index 0000000..f30ff1c
--- /dev/null
+++ b/.run/BlueWest-NoDocker.run.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/BlueWest.Api/Startup.cs b/BlueWest.Api/Startup.cs
index cbc6334..4074972 100644
--- a/BlueWest.Api/Startup.cs
+++ b/BlueWest.Api/Startup.cs
@@ -146,7 +146,7 @@ namespace BlueWest.WebApi
.AddSingleton();
- services.AddAuthServerServices( _configuration, _environment);
+ services.AddAuthServerServices( _configuration, _environment, configuration);
services.AddScoped();
diff --git a/BlueWest.Api/StartupExtensions.cs b/BlueWest.Api/StartupExtensions.cs
index 229b410..1ae0861 100644
--- a/BlueWest.Api/StartupExtensions.cs
+++ b/BlueWest.Api/StartupExtensions.cs
@@ -27,6 +27,25 @@ namespace BlueWest.WebApi
public static class StartupExtensions
{
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();
+ return config;
+ }
+ else
+ {
+ var config = configurationRoot.Get();
+ return config;
+ }
+
+ return null;
+ }
///
/// Get MYSQL Connection String
@@ -43,21 +62,9 @@ namespace BlueWest.WebApi
var sqlVersion = GetMySqlServerVersion(8, 0, 11);
// Docker / No-Docker
- var startupMode = configurationRoot["mode"];
-
- string mySqlConnectionString = String.Empty;
-
- if (startupMode == "docker")
- {
- var config = configuration.Get();
- if(config != null) mySqlConnectionString = config.MySql;
- }
- else
- {
- var config = configuration.Get();
- if(config != null) mySqlConnectionString = config.MySql;
- }
-
+
+ string mySqlConnectionString = configurationRoot.GetConnectionString().MySql;
+
if (mySqlConnectionString == string.Empty)
{
throw new InvalidOperationException("Fatal error: MySQL Connection string is 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
- .AddSingleton(new RedisConnectionProvider("redis://redisinstance:6379"))
+ .AddSingleton(new RedisConnectionProvider(connectionString.Redis))
.AddScoped()
.AddScoped()
.AddHostedService()
diff --git a/BlueWest.Api/config.json b/BlueWest.Api/config.json
index 22f4eb6..fb86f7e 100644
--- a/BlueWest.Api/config.json
+++ b/BlueWest.Api/config.json
@@ -1,5 +1,5 @@
{
- "mode": "docker",
+ "mode": "no-docker",
"database": "sqlite",
"environment": "dev"
}
\ No newline at end of file
diff --git a/data/dump.rdb b/data/dump.rdb
new file mode 100644
index 0000000000000000000000000000000000000000..5e04d971282bf38a518a0a95334a81e5b51356c2
GIT binary patch
literal 1397
zcmZuxOK;;;6n4^@KBkm*05L3(Gf@Q+O2YNEeH~{O#PPKgC$-!3l{l+9w%a(dlM<)R
zgNG;*VgUuQidu&RUv8>B(QADA6dc??cp(@MRTEPv;I=ez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22 @@
version: '3'
services:
db:
- container_name: BW1_DB_MYSQL
+ container_name: BW1_MYSQL
image: mysql/mysql-server:8.0
environment:
- MYSQL_ROOT_HOST: db
- MYSQL_USER_HOST: db
+ MYSQL_ROOT_HOST: localhost
+ MYSQL_USER_HOST: localhost
MYSQL_ROOT_PASSWORD: dXjw127124dJ
MYSQL_USER: blueuser
MYSQL_PASSWORD: dXjw127124dJ
MYSQL_DATABASE: bluedb
+ ports:
+ - "3306:3306"
volumes:
- ./docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
- phpmyadmin:
- container_name: BW_PHPMYADMIN
- image: phpmyadmin/phpmyadmin
- ports:
- - 80:80
- environment:
- MYSQL_USERNAME: 'blueuser'
- MYSQL_ROOT_PASSWORD: 'dXjw127124dJ'
- # ports:
- # - "3308:3306"
- redis:
- image: "redis:alpine"
- command: redis-server
+
+ redisinstance:
+ image: "redislabs/redismod"
ports:
- "6379:6379"
+ container_name: BW1_REDIS