# CI-byg til den self-hostede Forgejo runner (host-mode: jobs kører i runnerens
# egen Alpine-container, så 'container:' og apt-get virker ikke dér).
# Build og tests kører i stedet i SDK-imaget via docker build:
#   docker build -f deploy/ci/Dockerfile --target test .
#   docker buildx build -f deploy/ci/Dockerfile --target msi --build-arg VERSION=1.2.0 --output type=local,dest=dist .
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS test
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_NOLOGO=1
WORKDIR /src
COPY . .
RUN dotnet restore \
 && dotnet build --no-restore --configuration Release \
 && dotnet test --no-build --configuration Release --filter "Category!=Integration"

FROM mcr.microsoft.com/dotnet/sdk:10.0 AS msi-build
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 DOTNET_NOLOGO=1
RUN apt-get update -q && apt-get install -y -q --no-install-recommends wixl msitools python3 \
 && rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY . .
ARG VERSION=1.0.0
RUN installer/build-msi.sh "$VERSION"

FROM scratch AS msi
COPY --from=msi-build /src/dist/ /
