This commit is contained in:
Wieland, Marc
2026-06-26 14:56:19 +02:00
parent 7d9eac498a
commit 52842072e5
6 changed files with 51 additions and 1 deletions
+3
View File
@@ -27,15 +27,18 @@ COPY --from=build /app/publish .
# Directory for SQLite database
RUN mkdir -p /data
RUN mkdir -p /app/logs
ENV ASPNETCORE_HTTP_PORTS=8080
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_FORWARDEDHEADERS_ENABLED=true
ENV TIMETRACKER_DB_PATH=/data/timetracker.db
ENV TIMETRACKER_LOG_DIR=/app/logs
ENV EnableHttpsRedirect=false
EXPOSE 8080
VOLUME ["/data"]
VOLUME ["/app/logs"]
ENTRYPOINT ["dotnet", "timetracker.Server.dll"]
+21
View File
@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MudBlazor.Services;
using Serilog;
using timetracker.Server.Components;
using timetracker.Data;
using timetracker.Shared;
@@ -16,6 +17,24 @@ var builder = WebApplication.CreateBuilder(args);
const string SuperAdminUsername = "marc";
const string SuperAdminPassword = "123456";
var logDirectory = Environment.GetEnvironmentVariable("TIMETRACKER_LOG_DIR")
?? Path.Combine(builder.Environment.ContentRootPath, "logs");
Directory.CreateDirectory(logDirectory);
Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Configuration)
.Enrich.FromLogContext()
.WriteTo.Console()
.WriteTo.File(
Path.Combine(logDirectory, "timetracker-.log"),
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 14,
shared: true,
flushToDiskInterval: TimeSpan.FromSeconds(1))
.CreateLogger();
builder.Host.UseSerilog();
// Add Authentication
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
@@ -132,6 +151,8 @@ else
var app = builder.Build();
app.Logger.LogInformation("File logging active. Writing logs to {LogDirectory}", logDirectory);
// Migrate or Ensure Database Created
using (var scope = app.Services.CreateScope())
{
@@ -1,4 +1,14 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Information"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
+10
View File
@@ -1,4 +1,14 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.AspNetCore": "Warning",
"Microsoft.EntityFrameworkCore": "Information"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
@@ -14,6 +14,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.8" />
<PackageReference Include="MudBlazor" Version="9.4.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.2" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.3" />
</ItemGroup>