Spaces:
Running
Running
File size: 1,381 Bytes
2df0cf9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | {% 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 %}
|