This commit is contained in:
42
ChatBot/Dockerfile
Normal file
42
ChatBot/Dockerfile
Normal file
@@ -0,0 +1,42 @@
|
||||
# Build stage
|
||||
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
|
||||
WORKDIR /src
|
||||
|
||||
# Copy project file
|
||||
COPY ChatBot.csproj ./
|
||||
|
||||
# Restore dependencies
|
||||
RUN dotnet restore
|
||||
|
||||
# Copy all source files
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN dotnet build -c Release -o /app/build
|
||||
|
||||
# Publish stage
|
||||
FROM build AS publish
|
||||
RUN dotnet publish -c Release -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# Runtime stage
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS final
|
||||
WORKDIR /app
|
||||
|
||||
# Install PostgreSQL client for healthcheck (optional)
|
||||
RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Copy published application
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
# Create directory for logs
|
||||
RUN mkdir -p /app/logs && chmod 777 /app/logs
|
||||
|
||||
# Expose ports (if needed for health checks or metrics)
|
||||
EXPOSE 8080
|
||||
|
||||
# Health check
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD dotnet ChatBot.dll --health-check || exit 1
|
||||
|
||||
# Run the application
|
||||
ENTRYPOINT ["dotnet", "ChatBot.dll"]
|
||||
Reference in New Issue
Block a user