docker build fails at db migrations
All checks were successful
Gitea CI/CD / dotnet-build-and-test (push) Successful in 42s
Gitea CI/CD / Set Tag Name (push) Successful in 4s
Gitea CI/CD / docker-build-and-push (push) Successful in 1m33s
Gitea CI/CD / Create Tag (push) Successful in 4s

This commit is contained in:
2026-01-07 14:24:47 +01:00
parent 3fff8654fe
commit ae8b60687a
2 changed files with 26 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
services: services:
watcher: watcher:
image: git.triggermeelmo.com/watcher/watcher-server:latest image: git.triggermeelmo.com/triggermeelmo/watcher-server:latest
container_name: watcher container_name: watcher
# Resource Management # Resource Management
@@ -8,7 +8,6 @@ services:
resources: resources:
limits: limits:
memory: 200M memory: 200M
cpus: '0.5'
restart: unless-stopped restart: unless-stopped

View File

@@ -52,6 +52,31 @@ builder.Services.AddSwaggerGen(options =>
var app = builder.Build(); var app = builder.Build();
// Stelle sicher, dass das persistence-Verzeichnis existiert
var persistenceDir = Path.Combine(Directory.GetCurrentDirectory(), "persistence");
if (!Directory.Exists(persistenceDir))
{
Log.Information("Erstelle persistence-Verzeichnis: {PersistenceDir}", persistenceDir);
Directory.CreateDirectory(persistenceDir);
}
// Datenbank-Migration beim Start ausführen
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<WatcherDbContext>();
try
{
Log.Information("Führe Datenbank-Migrationen aus...");
dbContext.Database.Migrate();
Log.Information("Datenbank-Migrationen erfolgreich angewendet");
}
catch (Exception ex)
{
Log.Error(ex, "Fehler beim Ausführen der Datenbank-Migrationen");
throw;
}
}
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) if (!app.Environment.IsDevelopment())
{ {