Add Docker support

Docker configuration:
- Dockerfile: Multi-stage build with non-root user, health checks
- Dockerfile.migrations: Runs EF Core migrations on startup
- docker-compose.yml: Full stack with SQL Server, Azurite, app
- .dockerignore: Optimized build context
- .env.example: Template for API keys

Application changes:
- Added /health endpoint with EF Core database check
- Conditional HTTPS redirect (disabled in containers)
- DOTNET_RUNNING_IN_CONTAINER environment detection

Usage:
  cp .env.example .env  # Add your API keys
  docker-compose up -d  # Start all services

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 12:37:00 +01:00
parent 89d1f7e33b
commit c6d52a38b2
6 changed files with 245 additions and 1 deletions

26
Dockerfile.migrations Normal file
View File

@@ -0,0 +1,26 @@
# Migrations runner
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
# Install EF Core tools
RUN dotnet tool install --global dotnet-ef
ENV PATH="$PATH:/root/.dotnet/tools"
# Copy solution and project files
COPY TrueCV.sln ./
COPY src/TrueCV.Domain/TrueCV.Domain.csproj src/TrueCV.Domain/
COPY src/TrueCV.Application/TrueCV.Application.csproj src/TrueCV.Application/
COPY src/TrueCV.Infrastructure/TrueCV.Infrastructure.csproj src/TrueCV.Infrastructure/
COPY src/TrueCV.Web/TrueCV.Web.csproj src/TrueCV.Web/
# Restore dependencies
RUN dotnet restore
# Copy all source code
COPY src/ src/
# Build the project
RUN dotnet build src/TrueCV.Web/TrueCV.Web.csproj -c Release
# Run migrations on startup
ENTRYPOINT ["dotnet", "ef", "database", "update", "--project", "src/TrueCV.Infrastructure", "--startup-project", "src/TrueCV.Web", "--no-build", "-c", "Release"]