diff --git a/src/HeartTrackAPI/AppBootstrap.cs b/src/HeartTrackAPI/AppBootstrap.cs index 46d1ed9..ae980fa 100644 --- a/src/HeartTrackAPI/AppBootstrap.cs +++ b/src/HeartTrackAPI/AppBootstrap.cs @@ -76,6 +76,7 @@ public class AppBootstrap(IConfiguration configuration) //services.AddDbContext(); services.AddDbContext(options => options.UseSqlite(connectionString), ServiceLifetime.Singleton); + } else { @@ -104,7 +105,11 @@ public class AppBootstrap(IConfiguration configuration) { //services.AddSingleton(provider => new DbDataManager(provider.GetService())); //services.AddSingleton(); - services.AddSingleton(provider => new DbDataManager(provider.GetRequiredService())); + services.AddSingleton(provider => + { + provider.GetRequiredService().Database.EnsureCreated(); + return new DbDataManager(provider.GetRequiredService()); + }); //services.AddTransient(); } diff --git a/src/HeartTrackAPI/Dockerfile b/src/HeartTrackAPI/Dockerfile index 7e0afa4..64bcd55 100644 --- a/src/HeartTrackAPI/Dockerfile +++ b/src/HeartTrackAPI/Dockerfile @@ -4,8 +4,7 @@ COPY . . WORKDIR /src/HeartTrackAPI ARG BUILD_CONFIGURATION=Release -RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish -# /p:UseAppHost=false +RUN dotnet publish "HeartTrackAPI.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base USER $APP_UID diff --git a/src/HeartTrackAPI/Program.cs b/src/HeartTrackAPI/Program.cs index 04e64af..b3c209a 100644 --- a/src/HeartTrackAPI/Program.cs +++ b/src/HeartTrackAPI/Program.cs @@ -17,6 +17,6 @@ var app = builder.Build(); init.Configure(app, app.Environment); -app.Services.GetService()!.Database.EnsureCreated(); +app.Services.GetService().Database.EnsureCreated(); app.Run(); \ No newline at end of file