Persist data-protection keys to /keys when present (Coolify volume)
This commit is contained in:
@@ -3,10 +3,19 @@ using backend.Data;
|
|||||||
using backend.Devices;
|
using backend.Devices;
|
||||||
using backend.Install;
|
using backend.Install;
|
||||||
using backend.Pairing;
|
using backend.Pairing;
|
||||||
|
using Microsoft.AspNetCore.DataProtection;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
var keysDir = Environment.GetEnvironmentVariable("DataProtection__KeysDir") ?? "/keys";
|
||||||
|
if (Directory.Exists(keysDir))
|
||||||
|
{
|
||||||
|
builder.Services.AddDataProtection()
|
||||||
|
.PersistKeysToFileSystem(new DirectoryInfo(keysDir))
|
||||||
|
.SetApplicationName("smart-assistant");
|
||||||
|
}
|
||||||
|
|
||||||
builder.Services.AddDbContext<AppDbContext>(opt =>
|
builder.Services.AddDbContext<AppDbContext>(opt =>
|
||||||
opt.UseSqlite(builder.Configuration.GetConnectionString("Default")));
|
opt.UseSqlite(builder.Configuration.GetConnectionString("Default")));
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="9.*" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.*" />
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.*" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.*">
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.*">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user