docker-compose: force ASPNETCORE_ENVIRONMENT=Production on runtime
.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.
This commit is contained in:
parent
b320732ed4
commit
332e30db27
1 changed files with 9 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue