FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY Api/Api.csproj Api/
RUN dotnet restore Api/Api.csproj
COPY Api/ Api/
RUN dotnet publish Api/Api.csproj -c Release --no-restore -o /app

FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS api
RUN apt-get update && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app .
USER $APP_UID
EXPOSE 8080
ENTRYPOINT ["dotnet", "Api.dll"]

FROM build AS integration
COPY Tests/Tests.csproj Tests/
RUN dotnet restore Tests/Tests.csproj
COPY Tests/ Tests/
RUN dotnet build Tests/Tests.csproj -c Release --no-restore
ENTRYPOINT ["dotnet", "test", "Tests/Tests.csproj", "-c", "Release", "--no-build", "--logger", "console;verbosity=normal"]

FROM node:22-bookworm-slim AS bruno
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates && rm -rf /var/lib/apt/lists/* \
    && npm install --global @usebruno/cli@4.4.0 && npm cache clean --force
WORKDIR /collection
COPY bruno/ ./
COPY report/run.mjs /opt/festival/run.mjs
ENTRYPOINT ["bru"]
CMD ["run", "--env", "docker"]
