Spaces:
Running
Running
| {% if config.multiStage %} | |
| # Multi-stage build for .NET | |
| FROM mcr.microsoft.com/dotnet/sdk:{{ config.dotnetVersion or '8.0' }} AS builder | |
| WORKDIR /app | |
| # Copy csproj and restore dependencies | |
| COPY *.csproj ./ | |
| RUN dotnet restore | |
| # Copy everything else and build | |
| COPY . ./ | |
| RUN dotnet publish -c Release -o out | |
| # Production stage | |
| FROM mcr.microsoft.com/dotnet/aspnet:{{ config.dotnetVersion or '8.0' }} | |
| WORKDIR /app | |
| # Copy build output from builder | |
| COPY --from=builder /app/out . | |
| {% else %} | |
| # .NET {{ config.dotnetVersion or '8.0' }} Dockerfile | |
| FROM mcr.microsoft.com/dotnet/sdk:{{ config.dotnetVersion or '8.0' }} | |
| WORKDIR /app | |
| # Copy csproj and restore | |
| COPY *.csproj ./ | |
| RUN dotnet restore | |
| # Copy everything else | |
| COPY . ./ | |
| {% if not config.developmentMode %} | |
| # Build and publish | |
| RUN dotnet publish -c Release -o out | |
| {% endif %} | |
| {% endif %} | |
| # Expose port | |
| EXPOSE {{ config.port or '5000' }} | |
| {% if config.developmentMode %} | |
| # Development mode | |
| ENV ASPNETCORE_ENVIRONMENT=Development | |
| ENV ASPNETCORE_URLS=http://+:{{ config.port or '5000' }} | |
| CMD ["dotnet", "watch", "run"] | |
| {% else %} | |
| # Production mode | |
| ENV ASPNETCORE_ENVIRONMENT=Production | |
| ENV ASPNETCORE_URLS=http://+:{{ config.port or '5000' }} | |
| # Set memory and other runtime options | |
| ENV DOTNET_EnableDiagnostics=0 | |
| # Start application from published output | |
| CMD ["dotnet", "{{ config.projectName or 'app' }}.dll"] | |
| {% endif %} | |