Added distroless dockerfile. Updated docker compose

This commit is contained in:
2025-04-14 22:35:38 +02:00
parent b0fe27c643
commit f56f592c4c
4 changed files with 52 additions and 26 deletions

View File

@@ -1,37 +1,53 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER $APP_UID
# Prepare runtime docker image
FROM mcr.microsoft.com/dotnet/aspnet:8.0-noble-chiseled AS base
WORKDIR /app
# Prepare build image
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Install nodejs and npm so we can build tailwind
RUN apt-get update && apt-get install nodejs npm -y && apt-get clean
# Copy package.json file
WORKDIR /src
COPY ["Moonlight.Client/Styles/package.json", "Moonlight.Client/Styles/"]
# Install npm packages
WORKDIR /src/Moonlight.Client/Styles/
RUN npm i
# Copy project configuration files
WORKDIR /src
COPY ["Moonlight.ApiServer/Moonlight.ApiServer.csproj", "Moonlight.ApiServer/"]
COPY ["Moonlight.Client/Moonlight.Client.csproj", "Moonlight.Client/"]
COPY ["Moonlight.Shared/Moonlight.Shared.csproj", "Moonlight.Shared/"]
# Restore the nuget packages
RUN dotnet restore "Moonlight.ApiServer/Moonlight.ApiServer.csproj"
# Copy all files
COPY . .
WORKDIR "/src/Moonlight.ApiServer"
# Build tailwindcss
WORKDIR "/src/Moonlight.Client/Styles"
RUN npx tailwindcss -i style.css -o ../wwwroot/css/core.min.css --minify
# Build ApiServer project
WORKDIR "/src/Moonlight.ApiServer"
RUN dotnet build "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/build
# Publish application
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "Moonlight.ApiServer.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Create final small image with the built content
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Create storage directory a volume can bind to
RUN mkdir -p /app/storage
ENTRYPOINT ["dotnet", "Moonlight.ApiServer.dll"]