Prepare Network Aquarium for Coolify deployment
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
.git
|
||||
.gitignore
|
||||
.vs
|
||||
**/bin
|
||||
**/obj
|
||||
**/*.user
|
||||
**/*.suo
|
||||
**/appsettings.Development.json
|
||||
|
||||
src/WebsiteDna.Client
|
||||
src/WebsiteDna.Server
|
||||
src/WebsiteDna.Shared
|
||||
src/GuessTheSong.Client
|
||||
src/GuessTheSong.Shared
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
WORKDIR /source
|
||||
|
||||
COPY src/Aquarium.Shared/Aquarium.Shared.csproj src/Aquarium.Shared/
|
||||
COPY src/Aquarium.Client/Aquarium.Client.csproj src/Aquarium.Client/
|
||||
COPY src/Aquarium.Server/Aquarium.Server.csproj src/Aquarium.Server/
|
||||
|
||||
RUN dotnet restore src/Aquarium.Client/Aquarium.Client.csproj
|
||||
RUN dotnet restore src/Aquarium.Server/Aquarium.Server.csproj
|
||||
|
||||
COPY src/Aquarium.Shared/ src/Aquarium.Shared/
|
||||
COPY src/Aquarium.Client/ src/Aquarium.Client/
|
||||
COPY src/Aquarium.Server/ src/Aquarium.Server/
|
||||
|
||||
RUN dotnet publish src/Aquarium.Client/Aquarium.Client.csproj \
|
||||
--configuration Release \
|
||||
--output /artifacts/client \
|
||||
--no-restore
|
||||
|
||||
RUN dotnet publish src/Aquarium.Server/Aquarium.Server.csproj \
|
||||
--configuration Release \
|
||||
--output /artifacts/server \
|
||||
--no-restore
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
|
||||
WORKDIR /app
|
||||
|
||||
ENV ASPNETCORE_URLS=http://+:8080 \
|
||||
DOTNET_EnableDiagnostics=0
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
COPY --from=build /artifacts/server/ ./
|
||||
COPY --from=build /artifacts/client/wwwroot/ ./wwwroot/
|
||||
|
||||
USER app
|
||||
ENTRYPOINT ["dotnet", "Aquarium.Server.dll"]
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using Aquarium.Shared;
|
||||
|
||||
@@ -12,7 +13,7 @@ public class AquariumClientService : IAsyncDisposable
|
||||
private CancellationTokenSource? _localSimulationCts;
|
||||
private readonly Random _rnd = new();
|
||||
|
||||
public string ServerUrl { get; set; } = "http://localhost:5050/hubs/aquarium";
|
||||
public string ServerUrl { get; set; }
|
||||
public HubConnectionState ConnectionState => _hubConnection?.State ?? HubConnectionState.Disconnected;
|
||||
public bool IsUsingLocalSimulation { get; private set; } = false;
|
||||
public bool SoundEnabled { get; set; } = false;
|
||||
@@ -31,9 +32,11 @@ public class AquariumClientService : IAsyncDisposable
|
||||
public event Action? OnStateChanged;
|
||||
public event Action<TrafficEvent>? OnCreatureClicked;
|
||||
|
||||
public AquariumClientService(IJSRuntime js)
|
||||
public AquariumClientService(IJSRuntime js, NavigationManager navigation, IConfiguration configuration)
|
||||
{
|
||||
_js = js;
|
||||
ServerUrl = configuration["Aquarium:ServerUrl"]
|
||||
?? new Uri(new Uri(navigation.BaseUri), "hubs/aquarium").ToString();
|
||||
}
|
||||
|
||||
public async Task InitializeAsync(string canvasId)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"Aquarium": {
|
||||
"ServerUrl": "http://localhost:5050/hubs/aquarium"
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>🌊 Network Aquarium - Realtime Server Traffic Visualizer</title>
|
||||
<base href="/" />
|
||||
<link rel="preload" id="webassembly" />
|
||||
<link rel="stylesheet" href="css/app.css" />
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<script type="importmap"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@@ -25,7 +27,7 @@
|
||||
</div>
|
||||
|
||||
<script src="js/aquarium.js"></script>
|
||||
<script src="_framework/blazor.webassembly.js"></script>
|
||||
<script src="_framework/blazor.webassembly#[.{fingerprint}].js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -7,20 +7,9 @@ using Aquarium.Shared;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", policy =>
|
||||
{
|
||||
policy.SetIsOriginAllowed(_ => true)
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddSignalR(options =>
|
||||
{
|
||||
options.EnableDetailedErrors = true;
|
||||
options.EnableDetailedErrors = builder.Environment.IsDevelopment();
|
||||
options.MaximumReceiveMessageSize = 1024 * 1024; // 1 MB
|
||||
});
|
||||
|
||||
@@ -33,7 +22,8 @@ builder.Services.AddHostedService(sp => sp.GetRequiredService<TrafficBroadcaster
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles();
|
||||
|
||||
// Custom Middleware for live server traffic telemetry
|
||||
app.UseMiddleware<TrafficTelemetryMiddleware>();
|
||||
@@ -78,4 +68,7 @@ app.MapGet("/api/stats", (TrafficBroadcasterService broadcaster) =>
|
||||
|
||||
app.MapGet("/api/health", () => Results.Ok(new { status = "Healthy", server = "Network Aquarium Server", version = "1.0.0-net10" }));
|
||||
|
||||
// Serve the Blazor WebAssembly client for non-API routes.
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user