# Build Angular Web app
FROM node:24 AS web-build
WORKDIR /app/web
COPY Web/package*.json ./
RUN npm install
COPY Web/ ./
RUN npm run build -- --output-path=dist/Web/browser

# Build .NET Api app
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS api-build
WORKDIR /app/api
COPY Api/*.csproj ./
RUN dotnet restore
COPY Api/ ./
RUN dotnet publish Api.csproj -c Release -o /app/api/build

# Final runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
WORKDIR /app
COPY --from=api-build /app/api/build ./
COPY --from=web-build /app/web/dist/Web/browser ./wwwroot
ENV ASPNETCORE_URLS=http://+:5000
EXPOSE 5000
ENTRYPOINT ["dotnet", "Api.dll"]