From c2eed93e7c671048e42e0b29ccf4e235a3986cf5 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 8 Dec 2025 19:18:33 +0100 Subject: [PATCH] added Dockerfile and adapted build.yaml --- .gitea/workflows/build.yaml | 36 +++++++++++++++++++----------------- CouchLog/Dockerfile | 27 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 CouchLog/Dockerfile diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index e78ebc7..66cb2c7 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -1,45 +1,47 @@ -name: Docker Image Build & Push +name: .NET Docker Build & Push on: push: branches: - - 'main' # Baut bei jedem Commit auf main + - 'main' release: - types: [published] # Baut bei jedem neuen Release + types: [published] jobs: - push_to_registry: - runs-on: ubuntu-latest - permissions: - packages: write - contents: read + build_and_push: + runs-on: ubuntu-latest # Dein Runner mappt das ja auf Debian Bookworm + container: + image: catthehacker/ubuntu:act-latest # Optional, Standard-Umgebung für den Job selbst steps: - name: Check out the repo uses: actions/checkout@v4 - # 1. Login in die Gitea Container Registry + # Login in deine Gitea Registry - name: Log in to the Container registry uses: docker/login-action@v3 with: - registry: gitea.penry.de # <-- HIER DEINE GITEA URL ANPASSEN (ohne https://) + registry: gitea.penry.de # <-- ANPASSEN (ohne https://) username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # 2. Metadaten extrahieren (Das ist der magische Teil) - # Er sorgt dafür, dass bei einem Commit das Tag "main" oder "latest" genutzt wird - # und bei einem Release das Tag "v1.2.3" - - name: Extract metadata (tags, labels) for Docker + # Metadaten (Tags generieren: latest, v1.0, etc.) + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 with: - images: gitea.penry.de/${{ github.repository }} + images: gitea.penry.de/${{ github.repository }} # <-- ANPASSEN - # 3. Bauen und Pushen + # Der eigentliche Build. + # Da wir ein Multi-Stage Dockerfile haben, führt dieser Schritt + # automatisch "dotnet restore" und "dotnet publish" aus. - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . + file: ./Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} + # Wichtig für Raspberry Pi Builds, falls du Cross-Platform bauen willst (optional) + platforms: linux/arm64 \ No newline at end of file diff --git a/CouchLog/Dockerfile b/CouchLog/Dockerfile new file mode 100644 index 0000000..9ba07ea --- /dev/null +++ b/CouchLog/Dockerfile @@ -0,0 +1,27 @@ +# --- Stufe 1: Bauen (Build) --- +# Wir nutzen das SDK Image. Da du auf dem Pi bist, zieht Docker automatisch die ARM64 Version. +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build +WORKDIR /src + +# Wir kopieren erst nur die Projektdatei, um den Cache für "restore" zu nutzen +# ERSETZE "DeinProjektName.csproj" mit dem echten Namen deiner Datei! +COPY ["DeinProjektName.csproj", "./"] +RUN dotnet restore + +# Jetzt den Rest kopieren und bauen +COPY . . +# Wir erstellen die Release-Version im Ordner /app/publish +RUN dotnet publish -c Release -o /app/publish + +# --- Stufe 2: Ausführen (Runtime) --- +# Kleines Image, nur um die App zu starten (kein Compiler mehr drin) +FROM mcr.microsoft.com/dotnet/aspnet:10.0 +WORKDIR /app +EXPOSE 8080 + +# Wir kopieren die fertigen Dateien aus Stufe 1 hierher +COPY --from=build /app/publish . + +# Startbefehl +# ERSETZE "DeinProjektName.dll" mit dem echten Namen (meist gleich wie csproj) +ENTRYPOINT ["dotnet", "CouchLog.dll"] \ No newline at end of file