Skip to content

Commit

Permalink
Target .Net 8 and SSR (#135)
Browse files Browse the repository at this point in the history
* target .Net 8, updated docs and Dockerfile
* Move to SSR
* disable sticky session and WS from LB
  • Loading branch information
ShawkyZ authored Nov 22, 2023
1 parent 739c25d commit 63bcc0c
Show file tree
Hide file tree
Showing 84 changed files with 120 additions and 144 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
ENV SRC_DIR=/usr/src/MainSite
COPY src $SRC_DIR
RUN dotnet restore $SRC_DIR \
--runtime linux-x64
RUN dotnet publish $SRC_DIR/Client \
--runtime linux-x64 \
--framework net6.0 \
--framework net8.0 \
--self-contained \
--configuration Release \
--output /build

FROM mcr.microsoft.com/dotnet/aspnet:6.0
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /build .
EXPOSE 80
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The site was built using [Blazor](https://docs.microsoft.com/en-us/aspnet/core/blazor/) in Visual Studio.

## Install Dependencies
Requires .NET Core SDK 6.0
Requires .NET Core SDK 8.0

```powershell
PS> dotnet new -i Microsoft.AspNetCore.Blazor.Templates
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ services:
main-site:
build: .
ports:
- "8081:80"
- "8081:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
6 changes: 0 additions & 6 deletions kubernetes/main-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,9 @@ spec:
routes:
- conditions:
- prefix: /
enableWebsockets: true
services:
- name: #@ data.values.name
port: #@ int(data.values.service_port)
loadBalancerPolicy:
strategy: Cookie

#@ if/end data.values.www_hostname:
---
Expand All @@ -83,9 +80,6 @@ spec:
routes:
- conditions:
- prefix: /
enableWebsockets: true
services:
- name: #@ data.values.name
port: #@ int(data.values.service_port)
loadBalancerPolicy:
strategy: Cookie
10 changes: 0 additions & 10 deletions src/Client/App.razor

This file was deleted.

31 changes: 13 additions & 18 deletions src/Client/Pages/_Host.cshtml → src/Client/Components/App.razor
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
@page "/"
@namespace Steeltoe.Client.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
@inject IHostEnvironment HostEnvironment

<!DOCTYPE html>
<html lang="en">
Expand Down Expand Up @@ -48,32 +43,32 @@
<meta content="https://steeltoe.io/" name="DC.Identifier">
<meta content="Copyright 2017, VMware, Inc. All rights reserved." name="DC.Rights">

<base href="~/" />
<base href="/" />
<title>Steeltoe OSS</title>
<link rel="canonical" href="https://steeltoe.io/">
<link rel="icon" href="https://steeltoe.io/images/favicon.png" type="image/png" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/a11y-dark.min.css">
<link rel="stylesheet" href="css/site.css" />
<link rel="stylesheet" href="css/mobile.css" />
<HeadOutlet />
</head>
<body>

<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
@if (HostEnvironment.IsProduction())
{
<span>An error has occurred.</span>
}
else
{
<span>An unhandled exception occurred. See browser dev tools for details.</span>
}
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
<Routes />
<script src="js/functions.js" type="text/javascript"></script>
<script src="_framework/blazor.web.js"></script>
<script src="js/highlightjs-badge.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/languages/powershell.min.js" type="text/javascript"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits LayoutComponentBase
@inherits LayoutComponentBase
@inject NavigationManager NavigationManager

<header class="sticky-top bg-white" style="box-shadow: 0 0 20px -4px #eeeeee;">
Expand Down Expand Up @@ -35,4 +35,4 @@
private void Dispose() {
NavigationManager.LocationChanged -= LocationChanged;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Redirecting to new docs site, please hold.
private const string DefaultComponent = "welcome";
private DocsSiteOptions _docsSite;

#pragma warning disable BL0007
[Parameter]
public string Area
{
Expand All @@ -44,6 +45,7 @@ Redirecting to new docs site, please hold.
get => _version;
set => _version = (value is < 2 or > 3 or 0 ? CurrentVersion : value);
}
#pragma warning restore BL0007

protected override void OnInitialized()
{
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions src/Client/Components/Pages/Error.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@page "/Error"
@using System.Diagnostics

<PageTitle>Error</PageTitle>

<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>

@if (ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}

@code{
[CascadingParameter]
#nullable enable
private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
#nullable disable
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@page "/web-applications"
@page "/web-application"
@page "/web-applications"

<Template Name="Web Applications" Features="@features">
<Description>Steeltoe makes building web applications fast and hassle-free. By removing much of the boilerplate code and configuration associated with web development, you get a modern web programming model that streamlines the development of server-side HTML applications, REST APIs, and bidirectional, event-based systems.</Description>
Expand Down Expand Up @@ -93,4 +93,4 @@
Img = "/images/Icon_box.svg"
}
};
}
}
File renamed without changes.
8 changes: 8 additions & 0 deletions src/Client/Components/Routes.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@using Steeltoe.Client.Components.Layout

<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
</Router>

4 changes: 2 additions & 2 deletions src/Client/Components/Tab.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using Steeltoe.Client.UIInterfaces
@using Steeltoe.Client.Components.UIInterfaces
@implements ITab
@inject IJSRuntime JSRuntime

Expand Down Expand Up @@ -29,7 +29,7 @@

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JSRuntime.InvokeVoidAsync("highlightCode",true);
await JSRuntime.InvokeVoidAsync("highlightCode",true);
await base.OnAfterRenderAsync(firstRender);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Client/Components/TabSet.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using Steeltoe.Client.UIInterfaces
@using Steeltoe.Client.Components.UIInterfaces

<!-- Display the tab headers -->
<CascadingValue Value="this">
Expand Down
4 changes: 2 additions & 2 deletions src/Client/Components/Tip.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="tip">
<div class="tip">
<div class="row m-0" style="background-color:#1abc9c">
<div class="col-12 m-0 tip-title">tip</div>
</div>
<div class="row m-0" style="background-color:#dbfaf4">
<div class="col-12 m-0 tip-desc">
@Message
@ChildContent
@ChildContent
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/Client/Components/UIInterfaces/ITab.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Components;

namespace Steeltoe.Client.Components.UIInterfaces
{
public interface ITab
{
RenderFragment ChildContent { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@
@using Microsoft.JSInterop
@using Steeltoe.Client.Components
@using Steeltoe.Client.Models
@using Steeltoe.Client.Shared
62 changes: 46 additions & 16 deletions src/Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Steeltoe.Client.Components;
using Steeltoe.Client.Models;

namespace Steeltoe.Client
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddRazorComponents();

builder.Services.AddCors(options =>
{
public class Program
options.AddPolicy(name: "DocumentationPolicy",
policy =>
{
policy.WithOrigins("https://docs.steeltoe.io")
.AllowAnyHeader()
.WithMethods("GET");
});
});

builder.Services.Configure<CalendarEventOptions>(builder.Configuration.GetSection("CalendarEvents"));
builder.Services.AddHttpContextAccessor();
builder.Services.AddOptions<DocsSiteOptions>()
.Bind(builder.Configuration.GetSection("DocsSite"))
.ValidateDataAnnotations()
.PostConfigure(docsSiteOptions =>
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
docsSiteOptions.SetUrls();
});

var app = builder.Build();

if (builder.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
}

app.UseHttpsRedirection();

app.UseStaticFiles();

app.UseRouting();
app.UseAntiforgery();
app.UseCors("DocumentationPolicy");
app.MapRazorComponents<App>();

app.Run();
69 changes: 0 additions & 69 deletions src/Client/Startup.cs

This file was deleted.

Loading

0 comments on commit 63bcc0c

Please sign in to comment.