Added Dockerfile and adapted arm64 docker-arm64 workflow

This commit is contained in:
2025-12-11 20:45:43 +01:00
parent 44a2a61e2a
commit 2c59f6424f
3 changed files with 35 additions and 23 deletions

View File

@@ -1,24 +1,31 @@
# Stufe 1: Build-Umgebung (SDK)
# Wir nutzen das SDK Image, um den Code zu kompilieren
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Kopiere die Projektdatei (.csproj) und lade Abhängigkeiten
# Ersetze "DeinProjektName.csproj" evtl. durch "*.csproj", wenn du nur eine hast
COPY ../CouchLog/CouchLog.sln ./
RUN dotnet restore
# Kopiere zuerst nur die Projektdatei und lade Abhängigkeiten (Caching-Vorteil)
COPY ["../CouchLog/CouchLog.csproj", "."]
RUN dotnet restore "CouchLog.csproj"
# Kopiere den restlichen Code und baue die App (Release Modus)
COPY ../CouchLog/ ./
RUN dotnet publish -c Release -o /app/publish
# Kopiere den restlichen Source-Code
COPY ../CouchLog/ /src/
# --- Phase 2: Ausführen (Runtime Image) ---
# Das hier ist das eigentliche Image, das am Ende rauskommt (sehr klein)
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# Baue die Anwendung im Release-Modus
RUN dotnet build "CouchLog.csproj" -c Release -o /app/build
# Veröffentliche die Anwendung (Publish)
FROM build AS publish
RUN dotnet publish "CouchLog.csproj" -c Release -o /app/publish /p:UseAppHost=false
# Stufe 2: Runtime-Umgebung
# Das finale Image basiert auf dem schlanken ASP.NET Core Image
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# Wir kopieren die fertig gebaute App aus Phase 1 hier rein
COPY --from=build /app/publish .
# Kopiere die fertigen Dateien aus der Build-Stufe
COPY --from=publish /app/publish .
# WICHTIG: Ersetze "DeinProjektName.dll" mit dem echten Namen deiner DLL!
# Der Name ist meistens derselbe wie deine .csproj Datei.
# Startbefehl
ENTRYPOINT ["dotnet", "CouchLog.dll"]