# Hokm.Server (.NET 10 ASP.NET Core + SignalR)
# Build context = ./server  (so Hokm.Engine + Hokm.Server are both in scope)
FROM mirror.soroushasadi.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY nuget.docker.config /tmp/nuget.config
COPY Directory.Build.props ./
COPY src/ ./src/
RUN dotnet restore src/Hokm.Server/Hokm.Server.csproj --configfile /tmp/nuget.config
RUN dotnet publish src/Hokm.Server/Hokm.Server.csproj -c Release -o /out --no-restore

FROM mirror.soroushasadi.com/dotnet/aspnet:10.0
WORKDIR /app
# aspnet image ships no wget/curl — borrow busybox so the healthcheck has wget.
COPY --from=mirror.soroushasadi.com/busybox:1.36 /bin/busybox /usr/bin/wget
COPY --from=build /out ./
# Bind all interfaces (appsettings binds localhost only, unreachable across the port map).
ENV ASPNETCORE_URLS=http://0.0.0.0:5005
EXPOSE 5005
HEALTHCHECK --interval=10s --timeout=5s --retries=12 --start-period=20s \
  CMD wget -q -O- http://127.0.0.1:5005/ || exit 1
ENTRYPOINT ["dotnet", "Hokm.Server.dll"]
