This commit is contained in:
2024-02-20 17:15:27 +08:00
committed by huty
parent 6706e1a633
commit 34158042ad
1529 changed files with 177765 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
version: "3.7"
services:
ch02-hello-kiamol:
image: kiamol/ch02-hello-kiamol:latest-linux-amd64
ch02-whoami:
image: kiamol/ch02-whoami:latest-linux-amd64

View File

@@ -0,0 +1,8 @@
version: "3.7"
services:
ch02-hello-kiamol:
image: kiamol/ch02-hello-kiamol:latest-linux-arm64
ch02-whoami:
image: kiamol/ch02-whoami:latest-linux-arm64

View File

@@ -0,0 +1,12 @@
version: "3.7"
services:
ch02-hello-kiamol:
image: kiamol/ch02-hello-kiamol:latest
build:
context: ./hello-kiamol
ch02-whoami:
image: kiamol/ch02-whoami:latest
build:
context: ./whoami

View File

@@ -0,0 +1,2 @@
FROM nginx:1.21-alpine
COPY html/ /usr/share/nginx/html/

View File

@@ -0,0 +1,2 @@
# hello-diamol-web

View File

@@ -0,0 +1,15 @@
<html>
<body>
<h1>
Hello from Chapter 2!
</h1>
<h2>
This is
<a
href="https://www.manning.com/books/learn-kubernetes-in-a-month-of-lunches"
>Learn Kubernetes in a Month of Lunches</a
>.
</h2>
<h3>By <a href="https://blog.sixeyed.com">Elton Stoneman</a>.</h3>
</body>
</html>

View File

@@ -0,0 +1,10 @@
$images=$(yq e '.services.[].image' docker-compose.yml)
foreach ($image in $images)
{
docker manifest create --amend $image `
"$($image)-linux-arm64" `
"$($image)-linux-amd64"
docker manifest push $image
}

View File

@@ -0,0 +1,18 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as builder
WORKDIR /src
COPY src/whoami.csproj .
RUN dotnet restore
COPY src /src
RUN dotnet publish -c Release -o /out whoami.csproj
# app image
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine
EXPOSE 80
WORKDIR /app
ENTRYPOINT ["dotnet", "whoami.dll"]
COPY --from=builder /out/ .

View File

@@ -0,0 +1,22 @@
using System;
using System.Net;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
namespace whoami.Controllers
{
[Produces("application/json")]
[Route("/")]
public class WebController : Controller
{
private static string _Host = Dns.GetHostName();
[HttpGet]
public ActionResult<string> Get()
{
var osDescription = RuntimeInformation.OSDescription;
return $"I'm {_Host} running on {osDescription}";
}
}
}

View File

@@ -0,0 +1,18 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
namespace whoami
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
}

View File

@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace whoami
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}

View File

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