Dockerfile 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # =============================================================================
  2. # Multi-stage Dockerfile for Embase Conference Abstract Packaging Scheduler
  3. # Targets: .NET 8 Worker Service running on Linux
  4. # Optimized for: Small image size, security, and production deployment
  5. # =============================================================================
  6. # =============================================================================
  7. # Stage 1: Build
  8. # Uses the full SDK image to restore packages and build the application
  9. # =============================================================================
  10. FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
  11. WORKDIR /src
  12. # Copy project files for dependency restoration
  13. COPY ["src/EmbaseConferenceScheduler.Worker/EmbaseConferenceScheduler.Worker.csproj", "src/EmbaseConferenceScheduler.Worker/"]
  14. COPY ["src/EmbaseConferenceScheduler.Application/EmbaseConferenceScheduler.Application.csproj", "src/EmbaseConferenceScheduler.Application/"]
  15. COPY ["src/EmbaseConferenceScheduler.Domain/EmbaseConferenceScheduler.Domain.csproj", "src/EmbaseConferenceScheduler.Domain/"]
  16. COPY ["src/EmbaseConferenceScheduler.Infrastructure/EmbaseConferenceScheduler.Infrastructure.csproj", "src/EmbaseConferenceScheduler.Infrastructure/"]
  17. # Restore dependencies
  18. # This layer is cached unless project files change - improves build performance
  19. RUN dotnet restore "src/EmbaseConferenceScheduler.Worker/EmbaseConferenceScheduler.Worker.csproj"
  20. # Copy all source code
  21. COPY . .
  22. # Build the application
  23. WORKDIR "/src/src/EmbaseConferenceScheduler.Worker"
  24. RUN dotnet build "EmbaseConferenceScheduler.Worker.csproj" -c Release -o /app/build
  25. # =============================================================================
  26. # Stage 2: Publish
  27. # Creates a production-ready published output with optimizations
  28. # =============================================================================
  29. FROM build AS publish
  30. RUN dotnet publish "EmbaseConferenceScheduler.Worker.csproj" -c Release -o /app/publish /p:UseAppHost=false
  31. # =============================================================================
  32. # Stage 3: Runtime
  33. # Uses the minimal runtime image - significantly smaller than SDK
  34. # Only contains what's needed to run the application
  35. # =============================================================================
  36. FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS final
  37. # Set working directory
  38. WORKDIR /app
  39. # Create non-root user for security
  40. # Running as non-root is a security best practice
  41. RUN groupadd -r appuser && useradd -r -g appuser appuser
  42. # Copy published application from publish stage
  43. COPY --from=publish /app/publish .
  44. # Create directories for runtime operations (with proper permissions)
  45. RUN mkdir -p /app/temp /logs && chown -R appuser:appuser /app/temp /logs
  46. # Set ownership to non-root user
  47. RUN chown -R appuser:appuser /app
  48. # Switch to non-root user
  49. USER appuser
  50. # Set environment variables
  51. # These can be overridden at runtime via docker run -e or docker-compose
  52. ENV DOTNET_ENVIRONMENT=Production
  53. ENV TZ="Asia/Kolkata"
  54. # Entry point - starts the worker service
  55. ENTRYPOINT ["dotnet", "EmbaseConferenceScheduler.Worker.dll"]