forked from jakub/dotnettest
Initial Blazor Server Drone demo
This commit is contained in:
26
.drone.yml
Normal file
26
.drone.yml
Normal 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
11
Dockerfile
Normal 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
9
MyBlazorApp/App.razor
Normal 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>
|
||||
|
||||
6
MyBlazorApp/MyBlazorApp.csproj
Normal file
6
MyBlazorApp/MyBlazorApp.csproj
Normal file
@@ -0,0 +1,6 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
3
MyBlazorApp/Pages/Index.razor
Normal file
3
MyBlazorApp/Pages/Index.razor
Normal file
@@ -0,0 +1,3 @@
|
||||
@page "/"
|
||||
|
||||
<h1>Hello, Blazor world!</h1>
|
||||
23
MyBlazorApp/Pages/_Host.cshtml
Normal file
23
MyBlazorApp/Pages/_Host.cshtml
Normal 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
18
MyBlazorApp/Program.cs
Normal 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();
|
||||
|
||||
9
MyBlazorApp/_Imports.razor
Normal file
9
MyBlazorApp/_Imports.razor
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user