|
# Multi-stage build for ASP.NET Core application
|
|
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
|
WORKDIR /app
|
|
|
|
# Copy project files
|
|
COPY AISApp.csproj .
|
|
COPY . .
|
|
|
|
# Restore dependencies
|
|
RUN dotnet restore AISApp.csproj
|
|
|
|
# Build the application
|
|
RUN dotnet build AISApp.csproj -c Release -o /app/build
|
|
|
|
# Publish the application
|
|
RUN dotnet publish AISApp.csproj -c Release -o /app/publish
|
|
|
|
# Runtime stage
|
|
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy published application
|
|
COPY --from=build /app/publish .
|
|
|
|
# Copy prompt.txt file
|
|
COPY prompt.txt .
|
|
|
|
# Create directory for static files
|
|
RUN mkdir -p static
|
|
|
|
# Expose port
|
|
EXPOSE 80
|
|
|
|
# Set environment variables
|
|
ENV ASPNETCORE_URLS=http://+:80
|
|
ENV ASPNETCORE_ENVIRONMENT=Production
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
|
CMD curl -f http://localhost/api/chat || exit 1
|
|
|
|
# Run the application
|
|
ENTRYPOINT ["dotnet", "AISApp.dll"]
|