internal-comms
Write internal communications following company formats, including status reports, leadership updates, and newsletters.
ANanthropics/skills203k3,333 new stars in the last 7 days
Containerizing .NET 10 apps: multi-stage Dockerfile or Dockerfile-less SDK publish (`dotnet publish /t:PublishContainer`), non-root and chiseled images, layer caching, Compose, multi-arch. Use for "Docker", "Dockerfile", "docker-compose", "multi-stage", "PublishContainer", "chiseled", "container image". Do NOT use for CI pipeline YAML (use ci-cd) or Aspire AppHost orchestration (use aspire).
USER app by default since .NET 8. Never run as root in production..csproj files and restore before copying source code. This caches NuGet dependencies across builds.references/sdk-container-publish.md./health/live endpoint and let Kubernetes/Compose probe it. Chiseled and default aspnet images have no shell or curl, so in-image HEALTHCHECK commands have nothing to run with.<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ContainerRepository>mycompany/myapp-api</ContainerRepository>
<ContainerFamily>noble-chiseled</ContainerFamily>
</PropertyGroup>
dotnet publish /t:PublishContainer --os linux --arch x64
Why: settings live in the .csproj, so nothing drifts, and the result is an OCI image with the non-root app user and no shell. Always pass --os linux on Windows or you may get a Windows image. Chiseled variants, registries, multi-arch, tags, tarball output, and CI are in references/sdk-container-publish.md.
# Stage 1: Build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy project files and restore (cached layer)
COPY ["src/MyApp.Api/MyApp.Api.csproj", "src/MyApp.Api/"]
COPY ["src/MyApp.Domain/MyApp.Domain.csproj", "src/MyApp.Domain/"]
COPY ["Directory.Build.props", "."]
COPY ["Directory.Packages.props", "."]
RUN dotnet restore "src/MyApp.Api/MyApp.Api.csproj"
# Copy everything and build
COPY . .
RUN dotnet publish "src/MyApp.Api/MyApp.Api.csproj" \
-c Release \
-o /app/publish \
--no-restore
# Stage 2: Runtime
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS runtime
WORKDIR /app
# Non-root user (default in current .NET images)
USER app
COPY --from=build /app/publish .
EXPOSE 8080
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]
Prefer orchestrator-level probes (Kubernetes livenessProbe, Compose
healthcheck) over a Dockerfile HEALTHCHECK — the standard aspnet and
chiseled images ship no shell, no curl, and no wget, so there is nothing inside
the container to run the probe with. Point the orchestrator at /health/live:
# docker-compose — probe from outside the app process
services:
api:
healthcheck:
test: ["CMD-SHELL", "wget -qO- http://localhost:8080/health/live || exit 1"]
interval: 30s
timeout: 3s
retries: 3
# Note: CMD-SHELL requires a shell + wget in the image. Use a non-chiseled
# variant for this, or better: let Kubernetes httpGet probes do it —
# they run from the kubelet, needing nothing inside the image.
If you must have an in-image HEALTHCHECK, base the runtime stage on a
non-chiseled image that includes wget — never re-run the app binary as the
probe command; that starts a second instance instead of checking the first.
**/.git
**/.vs
**/bin
**/obj
**/node_modules
**/Dockerfile*
**/docker-compose*
**/tests
Key .NET-specific concerns — pass connection strings via environment, use depends_on with health checks:
services:
api:
build:
context: .
dockerfile: src/MyApp.Api/Dockerfile
ports:
- "5000:8080"
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ConnectionStrings__Default=Host=postgres;Database=myapp;Username=postgres;Password=postgres
- ConnectionStrings__Redis=redis:6379
depends_on:
postgres:
condition: service_healthy
# Add postgres/redis services with healthcheck — standard boilerplate
For solutions with multiple projects, restore only the necessary projects.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
# Copy solution and all project files
COPY *.slnx .
COPY Directory.Build.props .
COPY Directory.Packages.props .
COPY src/**/*.csproj ./src/
# Restore project structure
RUN for file in src/**/*.csproj; do \
mkdir -p $(dirname $file) && mv $file $(dirname $file)/; \
done
RUN dotnet restore
COPY . .
RUN dotnet publish src/MyApp.Api -c Release -o /app/publish --no-restore
// In Program.cs — lightweight health endpoint for Docker
app.MapGet("/health/live", () => Results.Ok("healthy"))
.ExcludeFromDescription();
# BAD — SDK image is 900MB+, includes compilers
FROM mcr.microsoft.com/dotnet/sdk:10.0
COPY . .
RUN dotnet run
# GOOD — separate build and runtime, runtime image is ~200MB
FROM mcr.microsoft.com/dotnet/aspnet:10.0
# BAD — any source change invalidates the NuGet cache
COPY . .
RUN dotnet restore
# GOOD — copy only project files first, then restore
COPY ["src/MyApp.Api/MyApp.Api.csproj", "src/MyApp.Api/"]
RUN dotnet restore "src/MyApp.Api/MyApp.Api.csproj"
COPY . .
# BAD — running as root (security risk)
FROM mcr.microsoft.com/dotnet/aspnet:10.0
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]
# GOOD — use the built-in non-root user
FROM mcr.microsoft.com/dotnet/aspnet:10.0
USER app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "MyApp.Api.dll"]
# BAD: 15 lines of Dockerfile that reproduce what MSBuild already does
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
# restore, publish, copy, USER app, EXPOSE, ENTRYPOINT ...
<!-- GOOD for a standard API or worker: properties in the csproj, no Dockerfile -->
<ContainerFamily>noble-chiseled</ContainerFamily>
Keep the Dockerfile when you need apt-get, native libraries, or extra build stages. SDK publish has no RUN equivalent; the workaround is a custom base image referenced by ContainerBaseImage.
| Scenario | Recommendation |
|---|---|
| Standard ASP.NET Core API | SDK container publish with noble-chiseled, or a multi-stage Dockerfile if the team prefers explicit control |
| Worker service / console app | SDK container publish, or Dockerfile with the dotnet/runtime image |
| Needs native OS packages or custom build steps | Dockerfile (or custom base image + SDK publish) |
| Azure Functions | Dockerfile (not supported by SDK publish) |
| CI without a Docker daemon | SDK publish with ContainerArchiveOutputPath tarball |
| Multi-arch (x64 + arm64) | ContainerRuntimeIdentifiers with SDK publish |
| Local development stack | Docker Compose with service dependencies |
| Dockerfile CI builds | Multi-stage build (self-contained) |
| Image size optimization | Chiseled base, or Alpine variant + trimming; Native AOT for the smallest image |
| Health monitoring | /health endpoint + orchestrator probe (K8s httpGet / Compose healthcheck) |
| Secrets | Environment variables or mounted secrets, never in image |
Write internal communications following company formats, including status reports, leadership updates, and newsletters.
ANanthropics/skills203k3,333 new stars in the last 7 days
GAgarrytan/gstack143k636 new stars in the last 7 days
ADaddyosmani/agent-skills122k1,627 new stars in the last 7 days
A pre-launch checklist covering monitoring, staged rollouts and rollback plans.
ADaddyosmani/agent-skills122k1,627 new stars in the last 7 days
PApaperclipai/paperclip119k2,120 new stars in the last 7 days
RUruvnet/RuView106k693 new stars in the last 7 days