diff --git a/Vulkan2Blazor.sln b/Vulkan2Blazor.sln index 93fc6bc..3d7fa8d 100644 --- a/Vulkan2Blazor.sln +++ b/Vulkan2Blazor.sln @@ -2,6 +2,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Vulkan2Blazor", "Vulkan2Blazor\Vulkan2Blazor.csproj", "{52A5CDEF-EFCB-4C24-82D0-2DCEC6E69FD3}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5DA684E1-853E-461D-AD1D-E7B14ADB7FB9}" + ProjectSection(SolutionItems) = preProject + compose.yaml = compose.yaml + .env = .env + compose-dev.yml = compose-dev.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/Vulkan2Blazor/Program.cs b/Vulkan2Blazor/Program.cs index 329e790..964da7d 100644 --- a/Vulkan2Blazor/Program.cs +++ b/Vulkan2Blazor/Program.cs @@ -28,7 +28,8 @@ .AddIdentityCookies(); builder.Services.AddDbContextFactory(options => - options.UseNpgsql(builder.Configuration.GetConnectionString("Vulkan2Context") ?? throw new InvalidOperationException("Connection string 'Vulkan2Context' not found."))); + options.UseNpgsql(builder.Configuration.GetConnectionString("Vulkan2Context") ?? + throw new InvalidOperationException("Connection string 'Vulkan2Context' not found."))); builder.Services.AddQuickGridEntityFrameworkAdapter(); @@ -48,8 +49,17 @@ builder.Services.AddSingleton, IdentityNoOpEmailSender>(); +builder.Services.AddControllers(); + var app = builder.Build(); +// Apply migrations on startup +using (var scope = app.Services.CreateScope()) +{ + var dbContext = scope.ServiceProvider.GetRequiredService(); + dbContext.Database.Migrate(); +} + // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { @@ -71,6 +81,8 @@ app.MapStaticAssets(); app.MapRazorComponents() .AddInteractiveServerRenderMode(); +app.MapBlazorHub(); +app.MapControllers(); // Add additional endpoints required by the Identity /Account Razor components. app.MapAdditionalIdentityEndpoints(); diff --git a/Vulkan2Blazor/Vulkan2Blazor.csproj b/Vulkan2Blazor/Vulkan2Blazor.csproj index 9616c12..6ab61d7 100644 --- a/Vulkan2Blazor/Vulkan2Blazor.csproj +++ b/Vulkan2Blazor/Vulkan2Blazor.csproj @@ -16,6 +16,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/compose-dev.yml b/compose-dev.yml new file mode 100644 index 0000000..070544c --- /dev/null +++ b/compose-dev.yml @@ -0,0 +1,38 @@ +services: + vulkan2blazor: + image: vulkan2blazor + build: + context: . + dockerfile: Vulkan2Blazor/Dockerfile + ports: + - "8080:8080" + environment: + ASPNETCORE_ENVIRONMENT: "Development" + # ASPNETCORE_URLS: "http://localhost:8080" + ConnectionStrings__Vulkan2Context: 'Host=postgres;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}' + depends_on: + postgres: + condition: service_healthy + # volumes: + # - vulkan2:/home/app/.aspnet/DataProtection-Keys + + postgres: + image: postgres + restart: always + user: postgres + env_file: + - .env + ports: + - "5432:5432" + volumes: + - postgres:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres: +# vulkan2: + diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..c7e7359 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,35 @@ +services: + vulkan2blazor: + image: vulkan2blazor:latest + ports: + - "8080:8080" + environment: + ASPNETCORE_ENVIRONMENT: "Development" +# ASPNETCORE_URLS: "http://localhost:8080" + ConnectionStrings__Vulkan2Context: 'Host=postgres;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD}' + depends_on: + postgres: + condition: service_healthy +# volumes: +# - vulkan2:/home/app/.aspnet/DataProtection-Keys + + postgres: + image: postgres + restart: always + user: postgres + env_file: + - .env + ports: + - "5432:5432" + volumes: + - postgres:/var/lib/postgresql/data + healthcheck: + test: ["CMD", "pg_isready"] + interval: 10s + timeout: 5s + retries: 5 + +volumes: + postgres: +# vulkan2: +