'COPY --from=${BUILD_ENV_IMAGE}' is rejected by BuildKit:
failed to solve: failed to parse stage name "${BUILD_ENV_IMAGE}":
invalid reference format: repository name
(library/${BUILD_ENV_IMAGE}) must be lowercase
A COPY --from= can only reference either a local stage of the
same Dockerfile, or a static image reference. ARG interpolation
in the stage name is not supported.
Replace the ARG + interpolation with the pinned tag in all
three Dockerfile.runtime* files. Bumping the build-env image
now means updating Dockerfile, Dockerfile.backend, and the three
Dockerfile.runtime* in lockstep.
58 lines
2.3 KiB
Text
58 lines
2.3 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 référence
|
|
# l'image de build par son tag pinné : changer le tag veut dire
|
|
# modifier les trois Dockerfile.runtime* en même temps.
|
|
COPY --from=pazof/yavsc-build-env:debian12-dotnet10-android36-v1 /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"]
|