Spaces:
Build error
Build error
| # ========================= | |
| # 1. Build stage | |
| # ========================= | |
| FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build | |
| WORKDIR /src | |
| # Copy project and restore | |
| COPY Blazor.csproj ./ | |
| RUN dotnet restore | |
| # Copy the rest of the source | |
| COPY . ./ | |
| # Publish the app (self-contained runtime layout) | |
| RUN dotnet publish \ | |
| -c Release \ | |
| -o /app/publish | |
| # ========================= | |
| # 2. Runtime stage | |
| # ========================= | |
| FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final | |
| # ---- Hugging Face requirement: run as app user with uid 1000 ---- | |
| # RUN useradd -m -u 1000 blazor | |
| # Make sure the HOME exists and is writable | |
| RUN mkdir -p /home/blazor && chown -R 1000:1000 /home/blazor | |
| # Instead of useradd, just ensure the username maps to UID 1000 | |
| USER 1000 | |
| # Optionally tell the shell the username you *want* displayed | |
| ENV USER=blazor \ | |
| HOME=/home/blazor \ | |
| PATH=/home/blazor/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # Copy published app with correct ownership | |
| COPY --chown=blazor --from=build /app/publish ./ | |
| # Hugging Face Docker Spaces expect your app to listen on 7860 | |
| # (you can change this with app_port in README if you want). | |
| EXPOSE 7860 | |
| # Tell Kestrel to bind to 0.0.0.0:7860 | |
| ENV ASPNETCORE_URLS=http://0.0.0.0:7860 | |
| # Just run the app | |
| ENTRYPOINT ["dotnet", "Blazor.dll"] |