docker: add Dockerfile.runtime / .blogs / .api for ASP.NET images
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.
This commit is contained in:
parent
d068ff4061
commit
7e99bbd54c
3 changed files with 126 additions and 0 deletions
33
Dockerfile.runtime.api
Normal file
33
Dockerfile.runtime.api
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Image runtime pour Yavsc.Api (API REST JSON principale, consommée
|
||||
# par les clients headless : PostIt, intégrations tierces, etc.).
|
||||
#
|
||||
# Cf. Dockerfile.runtime pour le pattern appsettings-org.json via
|
||||
# BuildKit secret mount, et le montage optionnel /etc/letsencrypt
|
||||
# pour HTTPS en production.
|
||||
#
|
||||
# docker build \
|
||||
# --secret id=yavsc_appsettings,src=./appsettings-org.json \
|
||||
# -f Dockerfile.runtime.api \
|
||||
# -t yavsc-api:dev .
|
||||
|
||||
# syntax=docker/dockerfile:1.7
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
ARG BUILD_ENV_IMAGE=pazof/yavsc-build-env:debian12-dotnet10-android36-v1
|
||||
COPY --from=${BUILD_ENV_IMAGE} /app/publish/Yavsc.Api/ ./
|
||||
|
||||
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
|
||||
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
ENV ASPNETCORE_URLS=http://+:5002
|
||||
|
||||
EXPOSE 5002
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD wget --quiet --spider http://localhost:5002/ || exit 1
|
||||
|
||||
ENTRYPOINT ["dotnet", "Yavsc.Api.dll"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue