Three new Dockerfiles, each producing a minimal runtime image based on mcr.microsoft.com/dotnet/aspnet:10.0: - Dockerfile.runtime : Yavsc.Org (port 5000 HTTP) - Dockerfile.runtime.blogs : Yavsc.Blogs (port 5004 HTTP) - Dockerfile.runtime.api : Yavsc.Api (port 5002 HTTP) Each one: 1. COPY --from=pazof/yavsc-build-env:debian12-dotnet10-android36-v1 /app/publish/<project>/ — i.e. the artifacts produced by the publish step added in the previous commit. 2. Injects appsettings-org.json via BuildKit secret mount (--mount=type=secret,id=yavsc_appsettings). The secret never lands in a layer — BuildKit copies it into /app and discards the mount. 3. Sets ASPNETCORE_URLS to the project's HTTP port and exposes it. 4. Adds a HEALTHCHECK that pings the root URL. HTTPS (ports 5001, 5003, 5005) is intentionally NOT exposed in the Dockerfile: enabling it requires mounting /etc/letsencrypt (typically via docker-compose) and configuring Kestrel:Certificates in appsettings-org.json. The compose file in the next commit documents the volume mount pattern.
59 lines
2.4 KiB
Text
59 lines
2.4 KiB
Text
# Image runtime pour Yavsc.Org (front web utilisateur-facing).
|
|
#
|
|
# Construit par-dessus l'image de build (qui produit /app/publish/Yavsc.Org)
|
|
# et copie l'artefact publié dans une image ASP.NET minimale.
|
|
#
|
|
# Le appsettings-org.json n'est PAS commit (le repo n'expose pas la
|
|
# configuration de prod). Il est injecté au build via un BuildKit secret
|
|
# mount, ex:
|
|
#
|
|
# docker build \
|
|
# --secret id=yavsc_appsettings,src=./appsettings-org.json \
|
|
# -f Dockerfile.runtime \
|
|
# -t yavsc-org:dev .
|
|
#
|
|
# En production le secret peut être fourni via le store CI (GitHub Actions
|
|
# secrets, etc.). Le chemin du fichier monté (/run/secrets/yavsc_appsettings)
|
|
# ne se retrouve PAS dans l'image finale : on le copie dans /app avant
|
|
# qu'il ne soit effacé du cache BuildKit.
|
|
#
|
|
# Pour activer HTTPS en production, monter un volume de certificats
|
|
# Letsencrypt (typiquement /etc/letsencrypt) en lecture :
|
|
#
|
|
# volumes:
|
|
# - /etc/letsencrypt:/etc/letsencrypt:ro
|
|
#
|
|
# et renseigner ASPNETCORE_URLS + Kestrel:Certificates dans la config.
|
|
# En dev local, on n'expose que HTTP (5000).
|
|
|
|
# syntax=docker/dockerfile:1.7
|
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
|
|
|
WORKDIR /app
|
|
|
|
# 1. Copier l'artefact publié depuis l'image de build. On ne référence
|
|
# pas pazof/yavsc-build-env:latest directement — le contexte de
|
|
# build (compose ou CI) contrôle quelle image source est utilisée.
|
|
ARG BUILD_ENV_IMAGE=pazof/yavsc-build-env:debian12-dotnet10-android36-v1
|
|
COPY --from=${BUILD_ENV_IMAGE} /app/publish/Yavsc.Org/ ./
|
|
|
|
# 2. appsettings-org.json : injecté via BuildKit secret mount.
|
|
# Le /run/secrets/... est un tmpfs éphémère, on copie dans /app puis
|
|
# le secret disparaît avec le cache BuildKit.
|
|
RUN --mount=type=secret,id=yavsc_appsettings,dst=/run/secrets/yavsc_appsettings \
|
|
cp /run/secrets/yavsc_appsettings /app/appsettings-org.json \
|
|
&& chmod 0644 /app/appsettings-org.json
|
|
|
|
# 3. ASPNETCORE_ENVIRONMENT=Production par défaut ; surchargeable au run.
|
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
|
ENV ASPNETCORE_URLS=http://+:5000
|
|
|
|
EXPOSE 5000
|
|
|
|
# Healthcheck simple : on ping /. ASP.NET répond 200 sur la racine en
|
|
# mode production ; si le binding échoue, le conteneur est marqué
|
|
# unhealthy et docker-compose peut le redémarrer.
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
|
CMD wget --quiet --spider http://localhost:5000/ || exit 1
|
|
|
|
ENTRYPOINT ["dotnet", "Yavsc.Org.dll"]
|