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
|
||||
|
||||
- name: Build Linux ARM64 Docker Image
|
||||
run: |
|
||||
# Wir bauen das Image und laden es (--load) in den lokalen Docker Daemon
|
||||
docker buildx build \
|
||||
--platform linux/arm64 \
|
||||
-t myapp:linux-arm64 \
|
||||
--load .
|
||||
run: docker build -t couchlog-arm64 .
|
||||
|
||||
- name: Save Docker Image to Tar
|
||||
# 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
|
||||
# Lädt die Datei in Gitea hoch
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: docker-image-arm64 # So heißt der Download-Button später
|
||||
path: my-image-arm64.tar
|
||||
name: couchlog-docker-image-arm64 # So heißt der Download-Button später
|
||||
path: CouchLog-arm64.tar
|
||||
if-no-files-found: error
|
||||
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
|
||||
WORKDIR /src
|
||||
|
||||
# Kopiere die Projektdatei (.csproj) und lade Abhängigkeiten
|
||||
# Ersetze "DeinProjektName.csproj" evtl. durch "*.csproj", wenn du nur eine hast
|
||||
COPY ../CouchLog/CouchLog.sln ./
|
||||
RUN dotnet restore
|
||||
# Kopiere zuerst nur die Projektdatei und lade Abhängigkeiten (Caching-Vorteil)
|
||||
COPY ["../CouchLog/CouchLog.csproj", "."]
|
||||
RUN dotnet restore "CouchLog.csproj"
|
||||
|
||||
# Kopiere den restlichen Code und baue die App (Release Modus)
|
||||
COPY ../CouchLog/ ./
|
||||
RUN dotnet publish -c Release -o /app/publish
|
||||
# Kopiere den restlichen Source-Code
|
||||
COPY ../CouchLog/ /src/
|
||||
|
||||
# --- Phase 2: Ausführen (Runtime Image) ---
|
||||
# Das hier ist das eigentliche Image, das am Ende rauskommt (sehr klein)
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
# 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
|
||||
|
||||
# Wir kopieren die fertig gebaute App aus Phase 1 hier rein
|
||||
COPY --from=build /app/publish .
|
||||
# Kopiere die fertigen Dateien aus der Build-Stufe
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# WICHTIG: Ersetze "DeinProjektName.dll" mit dem echten Namen deiner DLL!
|
||||
# Der Name ist meistens derselbe wie deine .csproj Datei.
|
||||
# Startbefehl
|
||||
ENTRYPOINT ["dotnet", "CouchLog.dll"]
|
||||
Reference in New Issue
Block a user