﻿FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src

COPY ["ITS.Models/", "ITS.Models/"]
COPY ["ITS.Core/", "ITS.Core/"]
COPY ["ITS.Interfaces/", "ITS.Interfaces/"]
COPY ["ITS.SQL/", "ITS.SQL/"]
COPY ["ITS.Storage/", "ITS.Storage/"]
COPY ["ITS.Storage.Dapr/", "ITS.Storage.Dapr/"]
COPY ["ITS.Storage.Azure/", "ITS.Storage.Azure/"]
COPY ["ITS.File.Stats/", "ITS.File.Stats/"]

COPY . .

WORKDIR /src/

RUN dotnet restore "ITS.Core/ITS.Core.csproj"
RUN dotnet restore "ITS.Models/ITS.Models.csproj"
RUN dotnet restore "ITS.Interfaces/ITS.Interfaces.csproj"
RUN dotnet restore "ITS.SQL/ITS.SQL.csproj"
RUN dotnet restore "ITS.Storage/ITS.Storage.csproj"
RUN dotnet restore "ITS.Storage.Dapr/ITS.Storage.Dapr.csproj"
RUN dotnet restore "ITS.Storage.Azure/ITS.Storage.Azure.csproj"
RUN dotnet restore "ITS.File.Stats/ITS.File.Stats.csproj"

FROM build AS compiledCodeStage
RUN dotnet build "ITS.File.Stats/ITS.File.Stats.csproj" -c Release -o /app

# Build runtime image
FROM mcr.microsoft.com/dotnet/runtime:6.0
ENV SQL_CONNECTION_STRING="Server=sqlserver;Database=ITS;User Id=sa;Password=Password1234;"

WORKDIR /app
COPY --from=compiledCodeStage /app .
ENTRYPOINT ["dotnet", "ITS.File.Stats.dll"]