Initial Blazor Server Drone demo

This commit is contained in:
2025-05-21 13:23:37 +02:00
commit ec13b6de0b
8 changed files with 105 additions and 0 deletions

26
.drone.yml Normal file
View File

@@ -0,0 +1,26 @@
kind: pipeline
type: docker
name: default
steps:
- name: docker-build
image: plugins/docker
settings:
repo: registry.example.com/myblazorapp
tags: latest
dockerfile: Dockerfile
username: your_registry_username
password: your_registry_password
- name: deploy
image: appleboy/drone-ssh
settings:
host: your-server.cz
username: deploy_user
key:
from_secret: ssh_private_key
script:
- docker pull registry.example.com/myblazorapp:latest
- docker stop myblazorapp || true
- docker rm myblazorapp || true
- docker run -d --name myblazorapp -p 8080:80 registry.example.com/myblazorapp:latest

11
Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY MyBlazorApp/ ./MyBlazorApp/
WORKDIR /src/MyBlazorApp
RUN dotnet publish -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "MyBlazorApp.dll"]

9
MyBlazorApp/App.razor Normal file
View File

@@ -0,0 +1,9 @@
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" />
</Found>
<NotFound>
<h1>Page not found</h1>
</NotFound>
</Router>

View File

@@ -0,0 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,3 @@
@page "/"
<h1>Hello, Blazor world!</h1>

View File

@@ -0,0 +1,23 @@
@page "/"
@namespace MyBlazorApp.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Hello Blazor</title>
<base href="~/" />
</head>
<body>
<app>
<component type="typeof(App)" render-mode="ServerPrerendered" />
</app>
<script src="_framework/blazor.server.js"></script>
</body>
</html>

18
MyBlazorApp/Program.cs Normal file
View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();

View File

@@ -0,0 +1,9 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using MyBlazorApp