added Dockerfile and Kaniko Build Stage
Some checks failed
Tests / Declarative: Post Actions No test results found
csharp-secdevops-pipeline-pod/pipeline/head There was a failure building this commit

This commit is contained in:
2026-05-06 12:39:16 +02:00
parent 6b52e54ef1
commit 23e44dc29f
2 changed files with 34 additions and 0 deletions

22
Dockerfile Normal file
View File

@@ -0,0 +1,22 @@
# --- Stage 1: Build (Die Bau-Umgebung) ---
FROM ://microsoft.com AS build-env
WORKDIR /app
# 1. Nur Projektdatei kopieren und Abhängigkeiten laden (Nutzt Docker-Caching)
COPY *.csproj ./
RUN dotnet restore
# 2. Den restlichen Quellcode kopieren und die App kompilieren
COPY . ./
RUN dotnet publish -c Release -o out
# --- Stage 2: Runtime (Das fertige, schlanke Image) ---
FROM ://microsoft.com
WORKDIR /app
# 3. Nur die fertigen Binärdateien aus der Bau-Umgebung rüberschieben
COPY --from=build-env /app/out .
# 4. Startbefehl festlegen
# WICHTIG: Falls deine DLL anders heißt (z.B. MyHelloWorld.dll), passe den Namen hier an!
ENTRYPOINT ["dotnet", "SecDevOpsLab.dll"]

12
Jenkinsfile vendored
View File

@@ -72,6 +72,18 @@ pipeline {
} }
} }
stage('Docker Build (Kaniko)') {
steps {
container('kaniko') {
// Wir bauen das Image lokal im Pod-Speicher
// --context `pwd`: Wo liegt dein Code? (Hier!)
// --dockerfile: Wo liegt das Dockerfile?
// --no-push: Nur bauen, noch nicht hochladen
sh '/kaniko/executor --context `pwd` --dockerfile `pwd`/Dockerfile --no-push'
}
}
}
stage('Set Build Name') { stage('Set Build Name') {
steps { steps {
script { script {