docker-dotnet-containerize
БесплатноБез исполняемых скриптовНе проверенGenerate production-ready Docker configurations for .NET APIs with multi-stage builds, Alpine optimization, layer caching, and build scripts. Use when…
Об этом скилле
.NET Docker Containerization Skill
Generate optimized Docker configurations for .NET projects using advanced build techniques, progressive layer publishing, and production-ready multi-stage builds.
What This Skill Does
I will analyze your .NET solution and generate:
- Optimized Dockerfile with BuildKit features and layer caching
- Build scripts (Bash/PowerShell) with version tagging
- .dockerignore file with comprehensive patterns
- Validation checklist and troubleshooting guidance
Advanced Techniques Applied
BuildKit Frontend (syntax=docker/dockerfile:1-labs)
I use the experimental BuildKit frontend for:
--parentsflag support (preserves directory structure)- Better caching mechanisms
- Advanced COPY operations
- Improved build performance
Progressive Layer Publishing
For complex projects, I publish in dependency order:
- Domain layer → Publish first (most stable)
- Infrastructure/EF Core → Publish second
- Application/HttpApi → Publish third
- API Host → Publish last (changes most)
Why? This creates separate layers in /app/publish, optimizing Docker layer caching. When you change only the API code, earlier layers remain cached.
Non-Alpine SDK with Alpine Runtime
- Build stage: Uses full SDK (not Alpine) for better compatibility
- Runtime stage: Uses Alpine for minimal footprint
- Benefit: Avoid Alpine SDK build issues while keeping final image small
Project Analysis
Detection Process
I'll examine:
- Solution file (
*.sln) location and structure - All project files (
*.csproj) and their dependencies - Main entry point (typically
*.Host,*.Api,*.HttpApi.Host) - .NET version from
<TargetFramework>tags - Existence of
common.props(ABP Framework indicator) - Project architecture (Simple, DDD, ABP, Clean Architecture)
Dependency Graph Mapping
I'll build a dependency graph to determine:
- Which projects reference which
- Optimal layer ordering for caching
- Whether progressive publishing is beneficial
Simple projects (≤3): Single publish step
Complex projects (≥4): Progressive multi-layer publishing
Dockerfile Generation
Standard Template Structure
# syntax=docker/dockerfile:1-labs
# BuildKit frontend for advanced features (--parents flag)
# Runtime base: Alpine for minimal size
FROM mcr.microsoft.com/dotnet/aspnet:{VERSION}-alpine AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
# Build stage: Full SDK (not Alpine) for compatibility
FROM mcr.microsoft.com/dotnet/sdk:{VERSION}-alpine AS publish
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# [Project-specific COPY and publish commands]
# Final runtime
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "{MainAssembly}.dll"]
Pattern 1: Simple Projects (2-3 projects)
# syntax=docker/dockerfile:1-labs
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS publish
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Copy project files with --parents (preserves structure)
COPY --parents src/MyProject.Models/MyProject.Models.csproj \
src/MyProject.Api/MyProject.Api.csproj \
/src/
# Restore dependencies (quiet mode)
RUN dotnet restore "./src/MyProject.Api/MyProject.Api.csproj" -v q
# Copy all source code
COPY --parents src/MyProject.Models/ \
src/MyProject.Api/ \
/src/
# Single publish step
RUN dotnet publish "src/MyProject.Api/MyProject.Api.csproj" \
-c $BUILD_CONFIGURATION \
-o /app/publish \
/p:UseAppHost=false \
-v q
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.Api.dll"]
Pattern 2: ABP Framework / Complex DDD (7+ projects)
# syntax=docker/dockerfile:1-labs
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS publish
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Copy solution-level configuration (ABP Framework)
COPY common.props ./
# Layer 1: Copy all project files for restore
COPY --parents src/Project.Domain.Shared/Project.Domain.Shared.csproj \
src/Project.Domain/Project.Domain.csproj \
src/Project.EntityFrameworkCore/Project.EntityFrameworkCore.csproj \
src/Project.Application.Contracts/Project.Application.Contracts.csproj \
src/Project.HttpApi/Project.HttpApi.csproj \
src/Project.Application/Project.Application.csproj \
src/Project.HttpApi.Host/Project.HttpApi.Host.csproj \
/src/
# Restore from entry point (restores all dependencies)
RUN dotnet restore "./src/Project.HttpApi.Host/Project.HttpApi.Host.csproj" -v q
# Layer 2: Publish Domain + EF Core (most stable, changes least)
COPY --parents
Установить docker-dotnet-containerize в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл docker-dotnet-containerize?
Generate production-ready Docker configurations for .NET APIs with multi-stage builds, Alpine optimization, layer caching, and build scripts. Use when containerizing .NET applications, creating Dockerfiles, or optimizing existing Docker setups.
Как установить скилл docker-dotnet-containerize?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл docker-dotnet-containerize запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub