Initialize Docker configuration
This commit is contained in:
parent
f7477e9f1c
commit
41f4fa93f0
5 changed files with 27 additions and 11 deletions
|
|
@ -6,15 +6,27 @@ namespace LANCommander.Server.Services
|
|||
{
|
||||
public class SettingService
|
||||
{
|
||||
private const string SettingsFilename = "Settings.yml";
|
||||
public static string WorkingDirectory { get; set; } = "";
|
||||
private const string FileName = "Settings.yml";
|
||||
|
||||
public static string SettingsFile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(WorkingDirectory))
|
||||
return Path.Combine(WorkingDirectory, FileName);
|
||||
else
|
||||
return FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private static Models.Settings Settings { get; set; }
|
||||
|
||||
public static Models.Settings LoadSettings()
|
||||
{
|
||||
if (File.Exists(SettingsFilename))
|
||||
if (File.Exists(SettingsFile))
|
||||
{
|
||||
var contents = File.ReadAllText(SettingsFilename);
|
||||
var contents = File.ReadAllText(SettingsFile);
|
||||
|
||||
var deserializer = new DeserializerBuilder()
|
||||
.IgnoreUnmatchedProperties()
|
||||
|
|
@ -49,7 +61,7 @@ namespace LANCommander.Server.Services
|
|||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.Build();
|
||||
|
||||
File.WriteAllText(SettingsFilename, serializer.Serialize(settings));
|
||||
File.WriteAllText(SettingsFile, serializer.Serialize(settings));
|
||||
|
||||
Settings = settings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ EXPOSE 35891/udp
|
|||
|
||||
COPY ./published /app
|
||||
|
||||
ENTRYPOINT ["dotnet", "LANCommander.Server.dll"]
|
||||
ENTRYPOINT ["dotnet", "LANCommander.Server.dll", "--docker"]
|
||||
|
|
@ -25,6 +25,9 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
if (args.Contains("--debugger"))
|
||||
WaitForDebugger();
|
||||
|
||||
if (args.Contains("--docker"))
|
||||
SettingService.WorkingDirectory = "/app/config";
|
||||
|
||||
builder.AddAsService();
|
||||
builder.AddLogger();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@
|
|||
switch (Settings.DatabaseProvider)
|
||||
{
|
||||
case DatabaseProvider.SQLite:
|
||||
Settings.DatabaseConnectionString = "Data Source=LANCommander.db;Cache=Shared";
|
||||
var dbPath = Path.Combine(SettingService.WorkingDirectory, "LANCommander.db");
|
||||
Settings.DatabaseConnectionString = $"Data Source={dbPath};Cache=Shared";
|
||||
break;
|
||||
|
||||
case DatabaseProvider.MySQL:
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@
|
|||
|
||||
StorageLocation MediaStorageLocation = new()
|
||||
{
|
||||
Path = "Media",
|
||||
Path = Path.Combine(SettingService.WorkingDirectory, "Media"),
|
||||
Type = StorageLocationType.Media,
|
||||
Default = true,
|
||||
};
|
||||
|
||||
StorageLocation SavesStorageLocation = new()
|
||||
{
|
||||
Path = "Saves",
|
||||
Path = Path.Combine(SettingService.WorkingDirectory, "Saves"),
|
||||
Type = StorageLocationType.Save,
|
||||
Default = true,
|
||||
};
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
if (!ArchiveStorageLocations.Any())
|
||||
ArchiveStorageLocations.Add(new StorageLocation
|
||||
{
|
||||
Path = "Uploads",
|
||||
Path = Path.Combine(SettingService.WorkingDirectory, "Uploads"),
|
||||
Type = StorageLocationType.Archive,
|
||||
Default = true,
|
||||
});
|
||||
|
|
@ -126,7 +126,7 @@
|
|||
|
||||
SavesStorageLocation = new StorageLocation
|
||||
{
|
||||
Path = "Saves",
|
||||
Path = Path.Combine(SettingService.WorkingDirectory, "Saves"),
|
||||
Type = StorageLocationType.Save,
|
||||
Default = true,
|
||||
};
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
|
||||
MediaStorageLocation = new StorageLocation
|
||||
{
|
||||
Path = "Media",
|
||||
Path = Path.Combine(SettingService.WorkingDirectory, "Media"),
|
||||
Type = StorageLocationType.Media,
|
||||
Default = true,
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue