init
This commit is contained in:
53
Dockerfile
Normal file
53
Dockerfile
Normal file
@@ -0,0 +1,53 @@
|
||||
# 1. Build-Phase: SDK-Image
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
WORKDIR /app
|
||||
|
||||
# Projektdateien kopieren und Abhängigkeiten wiederherstellen
|
||||
COPY *.sln .
|
||||
COPY Watcher/*.csproj ./Watcher/
|
||||
RUN dotnet restore
|
||||
|
||||
# Restliche Dateien kopieren und Build ausführen
|
||||
COPY Watcher/. ./Watcher/
|
||||
WORKDIR /app/Watcher
|
||||
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# 2. Laufzeit-Phase: ASP.NET Core Runtime
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
# Build-Argument für Version (wird zur Build-Zeit vom CI/CD gesetzt)
|
||||
ARG VERSION=latest
|
||||
|
||||
# Build-Argumente für UID/GID (Standard: 1000)
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=1000
|
||||
|
||||
# Install curl for health checks
|
||||
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create non-root user with configurable UID/GID
|
||||
RUN groupadd -r watcher -g ${USER_GID} && useradd -r -g watcher -u ${USER_UID} watcher
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /app/publish .
|
||||
|
||||
# Stelle sicher, dass Verzeichnisse existieren und Berechtigungen gesetzt sind
|
||||
RUN mkdir -p /app/persistence /app/wwwroot/downloads/sqlite /app/logs && \
|
||||
chown -R watcher:watcher /app
|
||||
|
||||
# Volumes
|
||||
VOLUME ["/app/persistence", "/app/wwwroot/downloads/sqlite", "/app/logs"]
|
||||
|
||||
# Switch to non-root user
|
||||
USER watcher
|
||||
|
||||
# Expose Port 5000
|
||||
EXPOSE 5000
|
||||
ENV ASPNETCORE_URLS=http://*:5000
|
||||
ENV ASPNETCORE_ENVIRONMENT=Production
|
||||
|
||||
# Version als Environment Variable setzen
|
||||
ENV WATCHER_VERSION=${VERSION}
|
||||
|
||||
# Anwendung starten
|
||||
ENTRYPOINT ["dotnet", "Watcher.dll"]
|
||||
Reference in New Issue
Block a user