63 lines
1.7 KiB
Docker
63 lines
1.7 KiB
Docker
# Base image
|
|
FROM cgr.dev/chainguard/aspnet-runtime:latest AS base
|
|
WORKDIR /app
|
|
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
|
|
|
# Build dependencies
|
|
RUN apt-get update; apt-get install nodejs npm -y; apt-get clean
|
|
|
|
# Build options
|
|
ARG BUILD_CONFIGURATION=Release
|
|
|
|
# Download npm packages
|
|
WORKDIR /src/Moonlight.Frontend/Styles
|
|
|
|
COPY ["Moonlight.Frontend/Styles/package.json", "package.json"]
|
|
|
|
RUN npm install
|
|
|
|
# Restore nuget packages
|
|
WORKDIR /src
|
|
|
|
COPY ["Moonlight.Api/Moonlight.Api.csproj", "Moonlight.Api/"]
|
|
COPY ["Moonlight.Frontend/Moonlight.Frontend.csproj", "Moonlight.Frontend/"]
|
|
COPY ["Moonlight.Shared/Moonlight.Shared.csproj", "Moonlight.Shared/"]
|
|
|
|
RUN dotnet restore "Moonlight.Api/Moonlight.Api.csproj"
|
|
RUN dotnet restore "Moonlight.Frontend/Moonlight.Frontend.csproj"
|
|
|
|
# Copy over the whole sources
|
|
COPY . .
|
|
|
|
# Build styles
|
|
WORKDIR /src/Moonlight.Frontend/Styles
|
|
RUN npm run tailwind-build
|
|
|
|
# Build projects
|
|
WORKDIR "/src/Moonlight.Api"
|
|
RUN dotnet build "./Moonlight.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build-api
|
|
|
|
WORKDIR "/src/Moonlight.Frontend"
|
|
RUN dotnet build "./Moonlight.Frontend.csproj" -c $BUILD_CONFIGURATION -o /app/build-frontend
|
|
|
|
FROM build AS publish
|
|
|
|
# Publish options
|
|
ARG BUILD_CONFIGURATION=Release
|
|
|
|
# Publish applications
|
|
WORKDIR "/src/Moonlight.Api"
|
|
RUN dotnet publish "./Moonlight.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish-api /p:UseAppHost=false
|
|
|
|
WORKDIR "/src/Moonlight.Frontend"
|
|
RUN dotnet publish "./Moonlight.Frontend.csproj" -c $BUILD_CONFIGURATION -o /app/publish-frontend /p:UseAppHost=false
|
|
|
|
FROM base AS final
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=publish /app/publish-api .
|
|
COPY --from=publish /app/publish-frontend/wwwroot ./wwwroot
|
|
|
|
ENTRYPOINT ["dotnet", "Moonlight.Api.dll"] |