41 lines
1.4 KiB
Docker
41 lines
1.4 KiB
Docker
# Stage 1: Runtime base
|
|
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS base
|
|
USER app
|
|
WORKDIR /app
|
|
EXPOSE 8080
|
|
|
|
# Stage 2: Build & Restore
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
|
WORKDIR /src
|
|
|
|
# Copy props and csproj files for layer caching
|
|
COPY ["Directory.Build.props", "./"]
|
|
COPY ["Directory.Packages.props", "./"]
|
|
COPY ["PostFundManagement.snk", "./"]
|
|
COPY ["LICENSE", "./"]
|
|
COPY ["PostFundManagement.Api/PostFundManagement.Api.csproj", "PostFundManagement.Api/"]
|
|
COPY ["PostFundManagement.Application/PostFundManagement.Application.csproj", "PostFundManagement.Application/"]
|
|
COPY ["PostFundManagement.Domain/PostFundManagement.Domain.csproj", "PostFundManagement.Domain/"]
|
|
COPY ["PostFundManagement.Infrastructure/PostFundManagement.Infrastructure.csproj", "PostFundManagement.Infrastructure/"]
|
|
|
|
# Restore packages
|
|
RUN dotnet restore "PostFundManagement.Api/PostFundManagement.Api.csproj"
|
|
|
|
# Copy full source code
|
|
COPY . .
|
|
|
|
# Build from the project folder using relative filename
|
|
WORKDIR "/src/PostFundManagement.Api"
|
|
RUN dotnet build "PostFundManagement.Api.csproj" -c Release -o /app/build
|
|
|
|
# Stage 3: Publish
|
|
FROM build AS publish
|
|
ARG BUILD_CONFIGURATION=Release
|
|
RUN dotnet publish "PostFundManagement.Api.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
|
# Stage 4: Final Runtime
|
|
FROM base AS final
|
|
WORKDIR /app
|
|
COPY --from=publish /app/publish .
|
|
ENTRYPOINT ["dotnet", "PostFundManagement.Api.dll"]
|