Complete Rebuild of Project from HelloWorld to Blazer WebApp
This commit is contained in:
16
Dockerfile
16
Dockerfile
@@ -3,20 +3,28 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
|
||||
WORKDIR /app
|
||||
|
||||
# 1. Nur Projektdatei kopieren und Abhängigkeiten laden (Nutzt Docker-Caching)
|
||||
COPY *.sln ./
|
||||
COPY MyHelloWorld/*.csproj ./MyHelloWorld/
|
||||
COPY MyHelloWorld.Tests/*.csproj ./MyHelloWorld.Tests/
|
||||
COPY *.csproj ./
|
||||
#COPY *.sln ./
|
||||
#COPY MyHelloWorld/*.csproj ./MyHelloWorld/
|
||||
#COPY MyHelloWorld.Tests/*.csproj ./MyHelloWorld.Tests/
|
||||
RUN dotnet restore
|
||||
|
||||
# 2. Den restlichen Quellcode kopieren und die App kompilieren
|
||||
COPY . ./
|
||||
RUN dotnet publish MyHelloWorld/*.csproj -c Release -o out
|
||||
#RUN dotnet publish MyHelloWorld/*.csproj -c Release -o out
|
||||
RUN dotnet publish "SecDevOpsLab.csproj" -c Release -o out
|
||||
|
||||
# --- Stage 2: Runtime (Das fertige, schlanke Image) ---
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine
|
||||
WORKDIR /app
|
||||
|
||||
# 3. Port für die Web-App öffnen (Standard bei .NET 8 Web-Apps ist 8080)
|
||||
EXPOSE 8080
|
||||
ENV ASPNETCORE_URLS=http://+:8080
|
||||
|
||||
# 3. Den vorinstallierten User 'app' von Microsoft nutzen
|
||||
# Erlaube dem User 'app' in das Verzeichnis zu schreiben (für SQLite)
|
||||
RUN chown -R app:app /app
|
||||
USER app
|
||||
|
||||
# 4. Nur die fertigen Binärdateien aus der Bau-Umgebung rüberschieben
|
||||
|
||||
Reference in New Issue
Block a user