From 332e30db2714d75e1dcb668b9155d9179a549296 Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Sat, 27 Jun 2026 17:29:34 +0100 Subject: [PATCH] docker-compose: force ASPNETCORE_ENVIRONMENT=Production on runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .env contains ASPNETCORE_ENVIRONMENT=Development, which gets loaded via env_file into every service. With ASPNETCORE_ENVIRONMENT=Development, ASP.NET Core loads appsettings-org.Development.json — which has a Kestrel:Endpoints block binding BOTH http://localhost:5000 AND https://localhost:5001. The HTTPS endpoint has no cert on a fresh host, so Kestrel crashes with: fail: Microsoft.Extensions.Hosting.Internal.Host[11] Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date. Fix: add an explicit ASPNETCORE_ENVIRONMENT=Production to each runtime service's environment: block. In Compose, literal environment: entries override env_file: entries with the same name, so this wins over .env's Development value. Production-loaded appsettings-org.json has no Kestrel block, so Kestrel uses only the ASPNETCORE_URLS env var we already set (http://+:5000 etc.) — HTTP only, no HTTPS crash. --- docker-compose.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker-compose.yaml b/docker-compose.yaml index d8e46871..65e552fe 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -39,6 +39,13 @@ services: environment: ASPNETCORE_URLS: "http://+:5000" ASPNETCORE_HTTPS_PORT: "" + # Forcer Production sur les services runtime : sans ça, + # appsettings-org.Development.json charge un bloc Kestrel + # avec un endpoint HTTPS qui crashe Kestrel (« No server + # certificate was specified »). Le bloc environment: dans + # Compose prend le pas sur la valeur ASPNETCORE_ENVIRONMENT + # du env_file: .env (qui contient Development). + ASPNETCORE_ENVIRONMENT: "Production" ports: - "5000:5000" # - "5001:5001" # HTTPS : activer avec le volume letsencrypt ci-dessous @@ -67,6 +74,7 @@ services: environment: ASPNETCORE_URLS: "http://+:5002" ASPNETCORE_HTTPS_PORT: "" + ASPNETCORE_ENVIRONMENT: "Production" ports: - "5002:5002" # - "5003:5003" # HTTPS : activer avec le volume letsencrypt ci-dessous @@ -97,6 +105,7 @@ services: environment: ASPNETCORE_URLS: "http://+:5004" ASPNETCORE_HTTPS_PORT: "" + ASPNETCORE_ENVIRONMENT: "Production" ports: - "5004:5004" # - "5005:5005" # HTTPS : activer avec le volume letsencrypt ci-dessous