31 lines
939 B
Docker
31 lines
939 B
Docker
# 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 zuerst nur die Projektdatei und lade Abhängigkeiten (Caching-Vorteil)
|
|
COPY ["../CouchLog/CouchLog.csproj", "."]
|
|
RUN dotnet restore "CouchLog.csproj"
|
|
|
|
# Kopiere den restlichen Source-Code
|
|
COPY ../CouchLog/ /src/
|
|
|
|
# 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
|
|
|
|
# Kopiere die fertigen Dateien aus der Build-Stufe
|
|
COPY --from=publish /app/publish .
|
|
|
|
# Startbefehl
|
|
ENTRYPOINT ["dotnet", "CouchLog.dll"] |