Implements Tasks 23 & 24: Backend and Frontend Dockerfiles Backend Dockerfiles: - Dockerfile.dev: Development with dotnet watch hot reload - Base: sdk:10.0, installs dotnet-ef tool - Layer caching: csproj files copied before source - Entry: dotnet watch run with --no-restore - Dockerfile: Production multi-stage build - Build stage: sdk:10.0, restore + build + publish - Runtime stage: aspnet:10.0-alpine (~110MB) - Health check: /health/live endpoint - Non-root: USER app (built-in) Frontend Dockerfiles: - Dockerfile.dev: Development with Bun hot reload - Base: node:22-alpine, installs Bun globally - Layer caching: package.json + bun.lock before source - Command: bun run dev - Dockerfile: Production standalone 3-stage build - Deps stage: Install with --frozen-lockfile - Build stage: bun run build → standalone output - Runner stage: node:22-alpine with non-root nextjs user - Copies: .next/standalone, .next/static, public - Health check: Node.js HTTP GET to port 3000 - Entry: node server.js (~240MB) All Dockerfiles use layer caching optimization and security best practices. Note: Docker build verification skipped (Docker daemon not running).
32 lines
1.0 KiB
Docker
32 lines
1.0 KiB
Docker
# Development Dockerfile for WorkClub.Api
|
|
# Enables hot reload via dotnet watch with volume mounts
|
|
FROM mcr.microsoft.com/dotnet/sdk:10.0
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dotnet-ef tool for migrations
|
|
RUN dotnet tool install --global dotnet-ef
|
|
ENV PATH="/root/.dotnet/tools:${PATH}"
|
|
|
|
# Layer caching: Copy solution and project files first
|
|
COPY WorkClub.slnx .
|
|
COPY global.json .
|
|
COPY WorkClub.Api/*.csproj ./WorkClub.Api/
|
|
COPY WorkClub.Application/*.csproj ./WorkClub.Application/
|
|
COPY WorkClub.Domain/*.csproj ./WorkClub.Domain/
|
|
COPY WorkClub.Infrastructure/*.csproj ./WorkClub.Infrastructure/
|
|
COPY WorkClub.Tests.Integration/*.csproj ./WorkClub.Tests.Integration/
|
|
COPY WorkClub.Tests.Unit/*.csproj ./WorkClub.Tests.Unit/
|
|
|
|
# Restore dependencies (cached layer)
|
|
RUN dotnet restore WorkClub.slnx
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Expose default ASP.NET Core port
|
|
EXPOSE 8080
|
|
|
|
# Hot reload: dotnet watch monitors file changes in mounted volumes
|
|
ENTRYPOINT ["dotnet", "watch", "run", "--project", "WorkClub.Api/WorkClub.Api.csproj", "--no-restore"]
|