Move version display to GET /api/health/version in HealthController

Uses GetApplicationVersion(Assembly.GetExecutingAssembly()) — the same
timestamp-based version already logged at startup and baked into the
assembly via the csproj <Version> property. Removes the minimal-API
/version endpoint from web/Program.cs and reverts the web Dockerfile
APP_VERSION build-arg (no longer needed).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-22 20:25:07 +03:00
parent 7441eb8cda
commit 6deb8dd4c8
5 changed files with 16 additions and 10 deletions
+1 -4
View File
@@ -47,10 +47,7 @@ jobs:
- name: Build Web image
run: |
APP_VERSION="1.0.$(git rev-list --count HEAD)"
docker build -f web/Dockerfile \
--build-arg APP_VERSION="${APP_VERSION}" \
-t "${REGISTRY_HOST}/${WEB_IMAGE}:${IMAGE_TAG}" .
docker build -f web/Dockerfile -t "${REGISTRY_HOST}/${WEB_IMAGE}:${IMAGE_TAG}" .
- name: Build CV cleanup job image
run: |
+14
View File
@@ -1,5 +1,7 @@
using System.Reflection;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using StartupHelpers;
using Swashbuckle.AspNetCore.Annotations;
namespace Api.Controllers
@@ -14,6 +16,18 @@ namespace Api.Controllers
[EnableCors("FrontendOnly")]
public sealed class HealthController : ControllerBase
{
/// <summary>
/// Returns the deployed API version.
/// </summary>
/// <returns>200 OK with JSON payload: { "version": "1.0.0-build.20250522103045" }</returns>
// GET api/health/version
[HttpGet("version")]
[SwaggerOperation(Summary = "API version", Description = "Returns the deployed API assembly version.")]
[SwaggerResponse(StatusCodes.Status200OK, "Version returned")]
[ProducesResponseType(StatusCodes.Status200OK)]
public IActionResult Version() =>
Ok(new { version = StartupExtensions.GetApplicationVersion(Assembly.GetExecutingAssembly()) });
/// <summary>
/// Liveness probe.
/// Indicates whether the process is running. Used by orchestration systems to confirm the process is alive.
-2
View File
@@ -13,8 +13,6 @@ FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
EXPOSE 8080
ENV ASPNETCORE_URLS=http://0.0.0.0:8080
ARG APP_VERSION=1.0.0
ENV APP_VERSION=${APP_VERSION}
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "web.dll"]
-3
View File
@@ -14,9 +14,6 @@ var app = builder.Build();
app.UseMiddleware<SiteModeMiddleware>();
app.MapGet("/version", (IConfiguration config) =>
Results.Json(new { version = config["APP_VERSION"] ?? "unknown" }));
// Static site
app.UseDefaultFiles();
app.UseStaticFiles();
+1 -1
View File
@@ -263,7 +263,7 @@
$('#year').text(new Date().getFullYear());
$.getJSON('/version').done(function (data) {
$.getJSON('/api/health/version').done(function (data) {
if (data && data.version) {
$('#app-version').text('v' + data.version);
}