# Use the official .NET 9.0 runtime as base image FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base WORKDIR /app # Install curl for health checks (if needed) RUN apt-get update && \ apt-get install -y procps && \ rm -rf /var/lib/apt/lists/* # Use the SDK image for building FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /src # Copy project files COPY TeleBot/TeleBot/TeleBot.csproj TeleBot/TeleBot/ COPY LittleShop.Client/LittleShop.Client.csproj LittleShop.Client/ # Restore dependencies RUN dotnet restore "TeleBot/TeleBot/TeleBot.csproj" # Copy all source code COPY . . # Build the application WORKDIR "/src/TeleBot/TeleBot" RUN dotnet build "TeleBot.csproj" -c Release -o /app/build # Publish the application FROM build AS publish RUN dotnet publish "TeleBot.csproj" -c Release -o /app/publish # Final runtime image FROM base AS final WORKDIR /app # Create necessary directories RUN mkdir -p logs data image_cache && \ chmod 755 logs data image_cache # Copy published application COPY --from=publish /app/publish . # Set environment variables ENV DOTNET_ENVIRONMENT=Production ENV TZ=UTC # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD pgrep -f "dotnet.*TeleBot" > /dev/null || exit 1 # Run the application ENTRYPOINT ["dotnet", "TeleBot.dll"]