# Builds the KHAOS AssettoServer plugins against the EXACT server release the
# lobbies run (plugins have no stable ABI; rebuild on every server bump).
#   docker build --build-arg AS_TAG=v0.0.55-pre45 --output type=local,dest=out .
# Output: out/<PluginName>/<PluginName>.dll (+ deps) -> /data/plugins/ per lobby.
FROM mcr.microsoft.com/dotnet/sdk:11.0-alpine AS build
ARG AS_TAG=v0.0.55-pre45
RUN apk add --no-cache git
WORKDIR /src
RUN git clone --depth 1 --branch ${AS_TAG} https://github.com/compujuckel/AssettoServer.git .
COPY KhaosPersonalWeatherPlugin/ Plugins/KhaosPersonalWeatherPlugin/
RUN dotnet publish Plugins/KhaosPersonalWeatherPlugin/KhaosPersonalWeatherPlugin.csproj \
      -c Release -r linux-x64 --self-contained false \
 && ls -la out-linux-x64/plugins/KhaosPersonalWeatherPlugin

FROM scratch
COPY --from=build /src/out-linux-x64/plugins/ /
