Added Dockerfile and adapted arm64 docker-arm64 workflow
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
**/.classpath
|
||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/bin
|
||||||
|
**/obj
|
||||||
|
**/node_modules
|
||||||
@@ -20,22 +20,17 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build Linux ARM64 Docker Image
|
- name: Build Linux ARM64 Docker Image
|
||||||
run: |
|
run: docker build -t couchlog-arm64 .
|
||||||
# Wir bauen das Image und laden es (--load) in den lokalen Docker Daemon
|
|
||||||
docker buildx build \
|
|
||||||
--platform linux/arm64 \
|
|
||||||
-t myapp:linux-arm64 \
|
|
||||||
--load .
|
|
||||||
|
|
||||||
- name: Save Docker Image to Tar
|
- name: Save Docker Image to Tar
|
||||||
# Jetzt exportieren wir das geladene Image in eine Datei
|
# Jetzt exportieren wir das geladene Image in eine Datei
|
||||||
run: docker save -o my-image-arm64.tar myapp:linux-arm64
|
run: docker save -o CouchLog-arm64.tar couchlog-arm64
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
# Lädt die Datei in Gitea hoch
|
# Lädt die Datei in Gitea hoch
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: docker-image-arm64 # So heißt der Download-Button später
|
name: couchlog-docker-image-arm64 # So heißt der Download-Button später
|
||||||
path: my-image-arm64.tar
|
path: CouchLog-arm64.tar
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1 # Optional: Wie lange die Datei gespeichert bleibt
|
retention-days: 1 # Optional: Wie lange die Datei gespeichert bleibt
|
||||||
35
Dockerfile
35
Dockerfile
@@ -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
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# Kopiere die Projektdatei (.csproj) und lade Abhängigkeiten
|
# Kopiere zuerst nur die Projektdatei und lade Abhängigkeiten (Caching-Vorteil)
|
||||||
# Ersetze "DeinProjektName.csproj" evtl. durch "*.csproj", wenn du nur eine hast
|
COPY ["../CouchLog/CouchLog.csproj", "."]
|
||||||
COPY ../CouchLog/CouchLog.sln ./
|
RUN dotnet restore "CouchLog.csproj"
|
||||||
RUN dotnet restore
|
|
||||||
|
|
||||||
# Kopiere den restlichen Code und baue die App (Release Modus)
|
# Kopiere den restlichen Source-Code
|
||||||
COPY ../CouchLog/ ./
|
COPY ../CouchLog/ /src/
|
||||||
RUN dotnet publish -c Release -o /app/publish
|
|
||||||
|
|
||||||
# --- Phase 2: Ausführen (Runtime Image) ---
|
# Baue die Anwendung im Release-Modus
|
||||||
# Das hier ist das eigentliche Image, das am Ende rauskommt (sehr klein)
|
RUN dotnet build "CouchLog.csproj" -c Release -o /app/build
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
|
||||||
|
# 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
|
WORKDIR /app
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
EXPOSE 8081
|
||||||
|
|
||||||
# Wir kopieren die fertig gebaute App aus Phase 1 hier rein
|
# Kopiere die fertigen Dateien aus der Build-Stufe
|
||||||
COPY --from=build /app/publish .
|
COPY --from=publish /app/publish .
|
||||||
|
|
||||||
# WICHTIG: Ersetze "DeinProjektName.dll" mit dem echten Namen deiner DLL!
|
# Startbefehl
|
||||||
# Der Name ist meistens derselbe wie deine .csproj Datei.
|
|
||||||
ENTRYPOINT ["dotnet", "CouchLog.dll"]
|
ENTRYPOINT ["dotnet", "CouchLog.dll"]
|
||||||
Reference in New Issue
Block a user