???: did some docker stuff. The Project can run, but the db needs to be linked from outside, or it does not work.
This commit is contained in:
parent
db1d4822d4
commit
f0fbb11824
4 changed files with 13 additions and 4 deletions
1
DockerRunCommand
Normal file
1
DockerRunCommand
Normal file
|
@ -0,0 +1 @@
|
|||
docker run --rm -it -p8080:80 -v/home/limited_dev/Documents/Code/School/imageboard/ImageBoardServerApp/Data/Nils.db:/app/Data/Nils.db ade4c760feb9
|
|
@ -16,6 +16,4 @@ RUN dotnet publish "ImageBoardServerApp/ImageBoardServerApp.csproj" -c Release -
|
|||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
RUN dotnet tool install --global dotnet-ef
|
||||
RUN dotnet ef database update
|
||||
ENTRYPOINT ["dotnet", "ImageBoardServerApp.dll"]
|
||||
|
|
|
@ -11,7 +11,9 @@ internal sealed class AppDBContext : DbContext
|
|||
public DbSet<ReportData> Reports { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
=> optionsBuilder.UseSqlite("Data Source=./Data/Nils.db");
|
||||
{
|
||||
optionsBuilder.UseSqlite("Data Source=./Data/Nils.db");
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder mb)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ImageBoardServerApp.Auth;
|
||||
using ImageBoardServerApp.Data;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
|
||||
|
||||
|
@ -10,6 +11,7 @@ builder.Services.AddRazorPages();
|
|||
builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddScoped<ProtectedSessionStorage>();
|
||||
builder.Services.AddScoped<AuthenticationStateProvider, CustomAuthenticationStateProvider>();
|
||||
builder.Services.AddSingleton<AppDBContext>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
|
@ -30,4 +32,10 @@ app.UseRouting();
|
|||
app.MapBlazorHub();
|
||||
app.MapFallbackToPage("/_Host");
|
||||
|
||||
using (var serviceScope = app.Services.CreateScope())
|
||||
{
|
||||
var context = serviceScope.ServiceProvider.GetService<AppDBContext>();
|
||||
context.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
app.Run();
|
Loading…
Reference in a new issue