Skip to content

Commit

Permalink
持久化数据保护
Browse files Browse the repository at this point in the history
  • Loading branch information
littletoxic committed Nov 29, 2024
1 parent 3c4a96e commit 4f109b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion deploy/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: blog

services:
blog-server:
image: littletoxic/blog-server
Expand All @@ -8,4 +10,9 @@ services:
- "/dev/i2c-1:/dev/i2c-1"
restart: unless-stopped
# non-root 容器中获取足够权限访问设备
user: '1654:994'
user: '1654:994'
volumes:
- server-secrets:/secrets

volumes:
server-secrets:
4 changes: 4 additions & 0 deletions src/LTBlog/LTBlog/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using LTBlog.Components;
using LTBlog.Data;
using LTBlog.Sensor;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -24,6 +25,9 @@

builder.Services.AddSensorWorker();

builder.Services.AddDataProtection()
.PersistKeysToFileSystem(new("/secrets/DataProtection-Keys"));

var app = builder.Build();

// Configure the HTTP request pipeline.
Expand Down

0 comments on commit 4f109b1

Please sign in to comment.