|
|
@@ -0,0 +1,65 @@
|
|
|
+# =============================================================================
|
|
|
+# Multi-stage Dockerfile for Elsevier Scheduler Service
|
|
|
+# Targets: .NET 8 Console/Scheduler App running on Linux
|
|
|
+# Optimized for: Small image size, security, and production deployment
|
|
|
+# =============================================================================
|
|
|
+
|
|
|
+# =============================================================================
|
|
|
+# Stage 1: Build
|
|
|
+# Uses the full SDK image to restore packages and build the application
|
|
|
+# =============================================================================
|
|
|
+FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
|
|
+WORKDIR /src
|
|
|
+
|
|
|
+# Copy solution file
|
|
|
+COPY ["Elsevier_Scheduler.sln", "./"]
|
|
|
+
|
|
|
+# Copy project file for dependency restoration
|
|
|
+COPY ["Elsevier_Scheduler/Elsevier_Scheduler.csproj", "Elsevier_Scheduler/"]
|
|
|
+
|
|
|
+# Restore dependencies
|
|
|
+# This layer is cached unless project files change - improves build performance
|
|
|
+RUN dotnet restore "Elsevier_Scheduler/Elsevier_Scheduler.csproj"
|
|
|
+
|
|
|
+# Copy all source code
|
|
|
+COPY . .
|
|
|
+
|
|
|
+# Build the application
|
|
|
+WORKDIR "/src/Elsevier_Scheduler"
|
|
|
+RUN dotnet build "Elsevier_Scheduler.csproj" -c Release -o /app/build
|
|
|
+
|
|
|
+# =============================================================================
|
|
|
+# Stage 2: Publish
|
|
|
+# Creates a production-ready published output with optimizations
|
|
|
+# =============================================================================
|
|
|
+FROM build AS publish
|
|
|
+RUN dotnet publish "Elsevier_Scheduler.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
|
|
+
|
|
|
+# =============================================================================
|
|
|
+# Stage 3: Runtime
|
|
|
+# Uses the minimal runtime image - significantly smaller than SDK
|
|
|
+# Only contains what's needed to run the application
|
|
|
+# =============================================================================
|
|
|
+FROM mcr.microsoft.com/dotnet/runtime:8.0 AS final
|
|
|
+
|
|
|
+# Set working directory
|
|
|
+WORKDIR /app
|
|
|
+
|
|
|
+# Create non-root user for security
|
|
|
+# Running as non-root is a security best practice
|
|
|
+RUN groupadd -r appuser && useradd -r -g appuser appuser
|
|
|
+
|
|
|
+# Copy published application from publish stage
|
|
|
+COPY --from=publish /app/publish .
|
|
|
+
|
|
|
+# Create temp directory for report file generation (with proper permissions)
|
|
|
+RUN mkdir -p /app/temp && chown -R appuser:appuser /app/temp
|
|
|
+
|
|
|
+# Set ownership to non-root user
|
|
|
+RUN chown -R appuser:appuser /app
|
|
|
+
|
|
|
+# Switch to non-root user
|
|
|
+USER appuser
|
|
|
+
|
|
|
+# Entry point - starts the scheduler service
|
|
|
+ENTRYPOINT ["dotnet", "Elsevier_Scheduler.dll"]
|