From fedd26bce6a34e3fe295652fa916a12be390f6a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Ren=C3=A9=20White=20Enciso?= Date: Sun, 8 Mar 2026 14:34:12 -0600 Subject: [PATCH] chore(thalos-service): add container run assets Why: align service runtime packaging and health endpoints for container execution. What: add Docker build assets, container runbook, and dual health mappings with explicit http/grpc ports. Rule: keep technical intent only and avoid orchestration references. --- .dockerignore | 9 +++++++++ Dockerfile | 23 +++++++++++++++++++++++ docs/runbooks/containerization.md | 25 +++++++++++++++++++++++++ src/Thalos.Service.Grpc/Program.cs | 10 ++++++++++ 4 files changed, 67 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docs/runbooks/containerization.md diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..636f769 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +**/bin/ +**/obj/ +.vs/ +TestResults/ +.git/ +.repo-tasks/ +.repo-context/ +.tasks/ +.agile/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fe895c0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +# syntax=docker/dockerfile:1.7 +ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0 +ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0 + +FROM ${SDK_IMAGE} AS build +ARG NUGET_FEED_URL=http://192.168.10.100:3000/api/packages/AgileWebs/nuget/index.json +ARG NUGET_FEED_USERNAME= +ARG NUGET_FEED_TOKEN= +WORKDIR /src +COPY . . + +RUN if [ -n "$NUGET_FEED_USERNAME" ] && [ -n "$NUGET_FEED_TOKEN" ]; then dotnet nuget add source "$NUGET_FEED_URL" --name gitea-org --username "$NUGET_FEED_USERNAME" --password "$NUGET_FEED_TOKEN" --store-password-in-clear-text --allow-insecure-connections --configfile /root/.nuget/NuGet/NuGet.Config; fi + +RUN dotnet restore "src/Thalos.Service.Grpc/Thalos.Service.Grpc.csproj" --configfile /root/.nuget/NuGet/NuGet.Config +RUN dotnet publish "src/Thalos.Service.Grpc/Thalos.Service.Grpc.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore + +FROM ${RUNTIME_IMAGE} AS runtime +WORKDIR /app +ENV ASPNETCORE_ENVIRONMENT=Production +EXPOSE 8080 +EXPOSE 8081 +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Thalos.Service.Grpc.dll"] diff --git a/docs/runbooks/containerization.md b/docs/runbooks/containerization.md new file mode 100644 index 0000000..4b2c190 --- /dev/null +++ b/docs/runbooks/containerization.md @@ -0,0 +1,25 @@ +# Containerization Runbook + +## Image Build + +If the repo consumes internal packages from Gitea, pass feed credentials as build args. + +```bash +docker build --build-arg NUGET_FEED_USERNAME= --build-arg NUGET_FEED_TOKEN= -t agilewebs/thalos-service:dev . +``` + +## Local Run + +```bash +docker run --rm -p 8080:8080 --name thalos-service agilewebs/thalos-service:dev +``` + +## Health Probe + +- Path: `/health` +- Fallback path: `/healthz` +- Port: `8080` + +## Runtime Notes + +- Exposes internal identity runtime endpoint set and gRPC service. diff --git a/src/Thalos.Service.Grpc/Program.cs b/src/Thalos.Service.Grpc/Program.cs index f52b4c2..0024e20 100644 --- a/src/Thalos.Service.Grpc/Program.cs +++ b/src/Thalos.Service.Grpc/Program.cs @@ -1,7 +1,16 @@ using Thalos.Service.Application.DependencyInjection; using Thalos.Service.Grpc.Services; +using Microsoft.AspNetCore.Server.Kestrel.Core; var builder = WebApplication.CreateBuilder(args); +var httpPort = builder.Configuration.GetValue("ThalosService:HttpPort", 8080); +var grpcPort = builder.Configuration.GetValue("ThalosService:GrpcPort", 8081); + +builder.WebHost.ConfigureKestrel(options => +{ + options.ListenAnyIP(httpPort, listenOptions => listenOptions.Protocols = HttpProtocols.Http1); + options.ListenAnyIP(grpcPort, listenOptions => listenOptions.Protocols = HttpProtocols.Http2); +}); builder.Services.AddGrpc(); builder.Services.AddHealthChecks(); @@ -11,5 +20,6 @@ var app = builder.Build(); app.MapGrpcService(); app.MapHealthChecks("/healthz"); +app.MapHealthChecks("/health"); app.Run();