Linux 환경에 최적화된 멀티 스테이지 Dockerfile과 .dockerignore 파일을 생성하여 ASP.NET Core 프로젝트를 컨테이너화합니다.
- GitHub 스타
- 41,038
- 파일
- 1
- 마지막 커밋
- 2026년 11월 11일
- 라이선스
- MIT
- 허용된 도구
- —
containerize-aspnetcore skill은 무엇을 하나요?
containerize-aspnetcore은(는) agent skill입니다. Linux 환경에 최적화된 멀티 스테이지 Dockerfile과 .dockerignore 파일을 생성하여 ASP.NET Core 프로젝트를 컨테이너화합니다.
skill의 SKILL.md에서 생성된 요약입니다.
containerize-aspnetcore skill 정보
이 SKILL은 ASP.NET Core 프로젝트를 Linux 환경으로 이전하려는 개발자를 위해 최적화된 Docker 구성을 생성합니다. 8.0 또는 9.0과 같은 특정 .NET 버전에 맞춘 멀티 스테이지 Dockerfile과 .dockerignore 파일 생성을 자동화합니다. 프로젝트의 .csproj 파일을 분석하여 올바른 대상 프레임워크를 결정하고 Debian, Alpine, Ubuntu, Chiseled 또는 Azure Linux를 포함한 적절한 Linux 배포판을 선택합니다.
커스텀 NuGet 피드, 시스템 패키지 또는 네이티브 라이브러리와 같은 특정 요구 사항이 있는 .NET 애플리케이션을 컨테이너화해야 할 때 에이전트가 이 SKILL을 로드해야 합니다. 이 프로세스는 패키지 복원, 애플리케이션 게시 및 런타임 구성을 처리하는 완전한 빌드 환경을 생성합니다. 또한 $APP_UID 변수를 통해 non-root 사용자를 구성하고 curl 또는 wget을 사용하여 health check 명령을 설정함으로써 보안과 성능을 관리합니다. 마지막으로 docker build 명령을 통해 설정을 검증하여 생성된 이미지가 정상적으로 작동하는지 확인하며 마무리합니다.
agent가 수행할 수 있는 작업
- 1Linux Dockerfile 생성특정 Linux 배포판을 대상으로 하는 ASP.NET Core 프로젝트용 멀티 스테이지 Dockerfile을 생성합니다.
- 2프로젝트 제외 항목 구성.dockerignore 파일을 설정하여 bin 또는 obj 폴더와 같은 불필요한 파일이 이미지에 포함되지 않도록 합니다.
- 3상태 모니터링 구현특정 URL 경로와 간격을 사용하여 컨테이너에 health check 명령을 추가합니다.
- 4프라이빗 의존성 관리인증이 필요한 프라이빗 NuGet 패키지 소스를 사용하도록 빌드 단계를 구성합니다.
skill의 SKILL.md를 기반으로 작성되었습니다. 모든 사용 사례는 해당 문서의 인용구와 대조 확인되었습니다.
containerize-aspnetcore skill 설치 방법
각 명령은 skill 폴더를 클라이언트의 skills 디렉터리에 복사합니다. 클라이언트를 재시작하거나 새 세션을 시작하여 로드하세요.Claude Code에 containerize-aspnetcore skill 설치
~/.claude/skills/containerize-aspnetcore/SKILL.md
$ npx degit github/awesome-copilot/skills/containerize-aspnetcore ~/.claude/skills/containerize-aspnetcoreClaude Code (project)에 containerize-aspnetcore skill 설치
.claude/skills/containerize-aspnetcore/SKILL.md
$ npx degit github/awesome-copilot/skills/containerize-aspnetcore .claude/skills/containerize-aspnetcoreCodex에 containerize-aspnetcore skill 설치
~/.agents/skills/containerize-aspnetcore/SKILL.md
$ npx degit github/awesome-copilot/skills/containerize-aspnetcore ~/.agents/skills/containerize-aspnetcoreGemini CLI에 containerize-aspnetcore skill 설치
~/.gemini/skills/containerize-aspnetcore/SKILL.md
$ npx degit github/awesome-copilot/skills/containerize-aspnetcore ~/.gemini/skills/containerize-aspnetcoreClaude.ai에 containerize-aspnetcore skill 설치
npx degit github/awesome-copilot/skills/containerize-aspnetcore containerize-aspnetcore && zip -r containerize-aspnetcore.zip containerize-aspnetcore # claude.ai → Customize → Skills → + → Create skill → Upload a skill → containerize-aspnetcore.zip
자동 검사
2026년 11월 15일에 실행됨전체 보고서 →자동 검사를 통과했습니다. 보안 감사는 아닙니다. 에이전트가 실행하기 전에 스크립트를 읽어 보세요. 검사 방식 · 점수를 높이기 위해 수정할 항목
- 소스 저장소 연결 및 접근 가능github/awesome-copilot/skills/containerize-aspnetcore is public and reachablegithub.com/github/awesome-copilot/tree/HEAD/skills/container ↗통과
- 오픈 소스 라이선스 (OSI)MITspdx.org/licenses/MIT.html ↗통과
- 최근 1년 내 커밋 또는 릴리스Last commit 2026-11-11github.com/github/awesome-copilot/commits ↗통과
- 스크립트에 다운로드 후 실행이나 자격 증명 탈취가 없음No scripts in the skill folder통과
- SKILL.md에 숨겨진 지침 없음No override phrases, safeguard switches, credential requests or hidden charactersgithub.com/github/awesome-copilot/blob/HEAD/skills/container ↗통과
- 사전 허용 도구가 제한됨No pre-approved tools; the agent asks before using onegithub.com/github/awesome-copilot/blob/HEAD/skills/container ↗통과
- SKILL.md가 Agent Skills 형식을 따름the description does not say when to use the skillgithub.com/github/awesome-copilot/blob/HEAD/skills/container ↗결함 발견
SKILL.md
GitHub에서 보기ASP.NET Core Docker Containerization Prompt
Containerization Request
Containerize the ASP.NET Core (.NET) project specified in the settings below, focusing exclusively on changes required for the application to run in a Linux Docker container. Containerization should consider all settings specified here.
Abide by best practices for containerizing .NET Core applications, ensuring that the container is optimized for performance, security, and maintainability.
Containerization Settings
This section of the prompt contains the specific settings and configurations required for containerizing the ASP.NET Core application. Prior to running this prompt, ensure that the settings are filled out with the necessary information. Note that in many cases, only the first few settings are required. Later settings can be left as defaults if they do not apply to the project being containerized.
Any settings that are not specified will be set to default values. The default values are provided in [square brackets].
Basic Project Information
-
Project to containerize:
[ProjectName (provide path to .csproj file)]
-
.NET version to use:
[8.0 or 9.0 (Default 8.0)]
-
Linux distribution to use:
[debian, alpine, ubuntu, chiseled, or Azure Linux (mariner) (Default debian)]
-
Custom base image for the build stage of the Docker image ("None" to use standard Microsoft base image):
[Specify base image to use for build stage (Default None)]
-
Custom base image for the run stage of the Docker image ("None" to use standard Microsoft base image):
[Specify base image to use for run stage (Default None)]
Container Configuration
-
Ports that must be exposed in the container image:
- Primary HTTP port:
[e.g., 8080] - Additional ports:
[List any additional ports, or "None"]
- Primary HTTP port:
-
User account the container should run as:
[User account, or default to "$APP_UID"]
-
Application URL configuration:
[Specify ASPNETCORE_URLS, or default to "http://+:8080"]
Build configuration
-
Custom build steps that must be performed before building the container image:
[List any specific build steps, or "None"]
-
Custom build steps that must be performed after building the container image:
[List any specific build steps, or "None"]
-
NuGet package sources that must be configured:
[List any private NuGet feeds with authentication details, or "None"]
Dependencies
-
System packages that must be installed in the container image:
[Package names for the chosen Linux distribution, or "None"]
-
Native libraries that must be copied to the container image:
[Library names and paths, or "None"]
-
Additional .NET tools that must be installed:
[Tool names and versions, or "None"]
System Configuration
- Environment variables that must be set in the container image:
[Variable names and values, or "Use defaults"]
File System
-
Files/directories that need to be copied to the container image:
[Paths relative to project root, or "None"]- Target location in container:
[Container paths, or "Not applicable"]
-
Files/directories to exclude from containerization:
[Paths to exclude, or "None"]
-
Volume mount points that should be configured:
[Volume paths for persistent data, or "None"]
.dockerignore Configuration
- Patterns to include in the
.dockerignorefile (.dockerignore will already have common defaults; these are additional patterns):- Additional patterns:
[List any additional patterns, or "None"]
- Additional patterns:
Health Check Configuration
-
Health check endpoint:
[Health check URL path, or "None"]
-
Health check interval and timeout:
[Interval and timeout values, or "Use defaults"]
Additional Instructions
-
Other instructions that must be followed to containerize the project:
[Specific requirements, or "None"]
-
Known issues to address:
[Describe any known issues, or "None"]
Scope
- ✅ App configuration modification to ensure application settings and connection strings can be read from environment variables
- ✅ Dockerfile creation and configuration for an ASP.NET Core application
- ✅ Specifying multiple stages in the Dockerfile to build/publish the application and copy the output to the final image
- ✅ Configuration of Linux container platform compatibility (Alpine, Ubuntu, Chiseled, or Azure Linux (Mariner))
- ✅ Proper handling of dependencies (system packages, native libraries, additional tools)
- ❌ No infrastructure setup (assumed to be handled separately)
- ❌ No code changes beyond those required for containerization
Execution Process
- Review the containerization settings above to understand the containerization requirements
- Create a
progress.mdfile to track changes with check marks - Determine the .NET version from the project's .csproj file by checking the
TargetFrameworkelement - Select the appropriate Linux container image based on:
- The .NET version detected from the project
- The Linux distribution specified in containerization settings (Alpine, Ubuntu, Chiseled, or Azure Linux (Mariner))
- If the user does not request specific base images in the containerization settings, then the base images MUST be valid mcr.microsoft.com/dotnet images with a tag as shown in the example Dockerfile, below, or in documentation
- Official Microsoft .NET images for build and runtime stages:
- SDK image tags (for build stage): https://github.com/dotnet/dotnet-docker/blob/main/README.sdk.md
- ASP.NET Core runtime image tags: https://github.com/dotnet/dotnet-docker/blob/main/README.aspnet.md
- .NET runtime image tags: https://github.com/dotnet/dotnet-docker/blob/main/README.runtime.md
- Create a Dockerfile in the root of the project directory to containerize the application
- The Dockerfile should use multiple stages:
- Build stage: Use a .NET SDK image to build the application
- Copy csproj file(s) first
- Copy NuGet.config if one exists and configure any private feeds
- Restore NuGet packages
- Then, copy the rest of the source code and build and publish the application to /app/publish
- Final stage: Use the selected .NET runtime image to run the application
- Set the working directory to /app
- Set the user as directed (by default, to a non-root user (e.g.,
$APP_UID))- Unless directed otherwise in containerization settings, a new user does not need to be created. Use the
$APP_UIDvariable to specify the user account.
- Unless directed otherwise in containerization settings, a new user does not need to be created. Use the
- Copy the published output from the build stage to the final image
- Build stage: Use a .NET SDK image to build the application
- Be sure to consider all requirements in the containerization settings:
- .NET version and Linux distribution
- Exposed ports
- User account for container
- ASPNETCORE_URLS configuration
- System package installation
- Native library dependencies
- Additional .NET tools
- Environment variables
- File/directory copying
- Volume mount points
- Health check configuration
- The Dockerfile should use multiple stages:
- Create a
.dockerignorefile in the root of the project directory to exclude unnecessary files from the Docker image. The.dockerignorefile MUST include at least the following elements as well as additional patterns as specified in the containerization settings:- bin/
- obj/
- .dockerignore
- Dockerfile
- .git/
- .github/
- .vs/
- .vscode/
- **/node_modules/
- *.user
- *.suo
- **/.DS_Store
- **/Thumbs.db
- Any additional patterns specified in the containerization settings
- Configure health checks if specified in the containerization settings:
- Add HEALTHCHECK instruction to Dockerfile if health check endpoint is provided
- Use curl or wget to check the health endpoint
- Mark tasks as completed: [ ] → [✓]
- Continue until all tasks are complete and Docker build succeeds
Build and Runtime Verification
Confirm that Docker build succeeds once the Dockerfile is completed. Use the following command to build the Docker image:
docker build -t aspnetcore-app:latest .
If the build fails, review the error messages and make necessary adjustments to the Dockerfile or project configuration. Report success/failure.
Progress Tracking
Maintain a progress.md file with the following structure:
# Containerization Progress
## Environment Detection
- [ ] .NET version detection (version: ___)
- [ ] Linux distribution selection (distribution: ___)
## Configuration Changes
- [ ] Application configuration verification for environment variable support
- [ ] NuGet package source configuration (if applicable)
## Containerization
- [ ] Dockerfile creation
- [ ] .dockerignore file creation
- [ ] Build stage created with SDK image
- [ ] csproj file(s) copied for package restore
- [ ] NuGet.config copied if applicable
- [ ] Runtime stage created with runtime image
- [ ] Non-root user configuration
- [ ] Dependency handling (system packages, native libraries, tools, etc.)
- [ ] Health check configuration (if applicable)
- [ ] Special requirements implementation
## Verification
- [ ] Review containerization settings and make sure that all requirements are met
- [ ] Docker build success
Do not pause for confirmation between steps. Continue methodically until the application has been containerized and Docker build succeeds.
YOU ARE NOT DONE UNTIL ALL CHECKBOXES ARE MARKED! This includes building the Docker image successfully and addressing any issues that arise during the build process.
Example Dockerfile
An example Dockerfile for an ASP.NET Core (.NET) application using a Linux base image.
# ============================================================
# Stage 1: Build and publish the application
# ============================================================
# Base Image - Select the appropriate .NET SDK version and Linux distribution
# Possible tags include:
# - 8.0-bookworm-slim (Debian 12)
# - 8.0-noble (Ubuntu 24.04)
# - 8.0-alpine (Alpine Linux)
# - 9.0-bookworm-slim (Debian 12)
# - 9.0-noble (Ubuntu 24.04)
# - 9.0-alpine (Alpine Linux)
# Uses the .NET SDK image for building the application
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
# Copy project files first for better caching
COPY ["YourProject/YourProject.csproj", "YourProject/"]
COPY ["YourOtherProject/YourOtherProject.csproj", "YourOtherProject/"]
# Copy NuGet configuration if it exists
COPY ["NuGet.config", "."]
# Restore NuGet packages
RUN dotnet restore "YourProject/YourProject.csproj"
# Copy source code
COPY . .
# Perform custom pre-build steps here, if needed
# RUN echo "Running pre-build steps..."
# Build and publish the application
WORKDIR "/src/YourProject"
RUN dotnet build "YourProject.csproj" -c $BUILD_CONFIGURATION -o /app/build
# Publish the application
RUN dotnet publish "YourProject.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# Perform custom post-build steps here, if needed
# RUN echo "Running post-build steps..."
# ============================================================
# Stage 2: Final runtime image
# ============================================================
# Base Image - Select the appropriate .NET runtime version and Linux distribution
# Possible tags include:
# - 8.0-bookworm-slim (Debian 12)
# - 8.0-noble (Ubuntu 24.04)
# - 8.0-alpine (Alpine Linux)
# - 8.0-noble-chiseled (Ubuntu 24.04 Chiseled)
# - 8.0-azurelinux3.0 (Azure Linux)
# - 9.0-bookworm-slim (Debian 12)
# - 9.0-noble (Ubuntu 24.04)
# - 9.0-alpine (Alpine Linux)
# - 9.0-noble-chiseled (Ubuntu 24.04 Chiseled)
# - 9.0-azurelinux3.0 (Azure Linux)
# Uses the .NET runtime image for running the application
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS final
# Install system packages if needed (uncomment and modify as needed)
# RUN apt-get update && apt-get install -y \
# curl \
# wget \
# ca-certificates \
# libgdiplus \
# && rm -rf /var/lib/apt/lists/*
# Install additional .NET tools if needed (uncomment and modify as needed)
# RUN dotnet tool install --global dotnet-ef --version 8.0.0
# ENV PATH="$PATH:/root/.dotnet/tools"
WORKDIR /app
# Copy published application from build stage
COPY --from=build /app/publish .
# Copy additional files if needed (uncomment and modify as needed)
# COPY ./config/appsettings.Production.json .
# COPY ./certificates/ ./certificates/
# Set environment variables
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:8080
# Add custom environment variables if needed (uncomment and modify as needed)
# ENV CONNECTIONSTRINGS__DEFAULTCONNECTION="your-connection-string"
# ENV FEATURE_FLAG_ENABLED=true
# Configure SSL/TLS certificates if needed (uncomment and modify as needed)
# ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/app/certificates/app.pfx
# ENV ASPNETCORE_Kestrel__Certificates__Default__Password=your_password
# Expose the port the application listens on
EXPOSE 8080
# EXPOSE 8081 # Uncomment if using HTTPS
# Install curl for health checks if not already present
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
# Configure health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Create volumes for persistent data if needed (uncomment and modify as needed)
# VOLUME ["/app/data", "/app/logs"]
# Switch to non-root user for security
USER $APP_UID
# Set the entry point for the application
ENTRYPOINT ["dotnet", "YourProject.dll"]
Adapting this Example
Note: Customize this template based on the specific requirements in containerization settings.
When adapting this example Dockerfile:
- Replace
YourProject.csproj,YourProject.dll, etc. with your actual project names - Adjust the .NET version and Linux distribution as needed
- Modify the dependency installation steps based on your requirements and remove any unnecessary ones
- Configure environment variables specific to your application
- Add or remove stages as needed for your specific workflow
- Update the health check endpoint to match your application's health check route
Linux Distribution Variations
Alpine Linux
For smaller image sizes, you can use Alpine Linux:
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
# ... build steps ...
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
# Install packages using apk
RUN apk update && apk add --no-cache curl ca-certificates
Ubuntu Chiseled
For minimal attack surface, consider using chiseled images:
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS final
# Note: Chiseled images have minimal packages, so you may need to use a different base for additional dependencies
Azure Linux (Mariner)
For Azure-optimized containers:
FROM mcr.microsoft.com/dotnet/aspnet:8.0-azurelinux3.0 AS final
# Install packages using tdnf
RUN tdnf update -y && tdnf install -y curl ca-certificates && tdnf clean all
Notes on Stage Naming
- The
AS stage-namesyntax gives each stage a name - Use
--from=stage-nameto copy files from a previous stage - You can have multiple intermediate stages that aren't used in the final image
- The
finalstage is the one that becomes the final container image
Security Best Practices
- Always run as a non-root user in production
- Use specific image tags instead of
latest - Minimize the number of installed packages
- Keep base images updated
- Use multi-stage builds to exclude build dependencies from the final image
이 스킬의 파일
1containerize-aspnetcore skill 질문
Claude Code에 containerize-aspnetcore skill을 어떻게 설치하나요?
npx degit github/awesome-copilot/skills/containerize-aspnetcore ~/.claude/skills/containerize-aspnetcore를 실행합니다. Claude Code는 ~/.claude/skills(모든 프로젝트) 또는 .claude/skills(한 프로젝트)에서 skills를 로드하며, 설명이 작업과 일치할 때 skill을 사용합니다.
containerize-aspnetcore skill을 사용할 수 있는 클라이언트는 무엇인가요?
Agent Skills 형식을 읽는 모든 클라이언트(Claude Code, Codex, Gemini CLI, claude.ai(ZIP으로 업로드))가 사용할 수 있습니다. skill 내 스크립트는 클라이언트가 코드 실행을 허용하는 경우에만 실행됩니다.
어떤 Linux 배포판을 컨테이너로 사용할 수 있나요?
debian, alpine, ubuntu, chiseled 또는 Azure Linux (mariner)를 지원합니다.
이 SKILL이 인프라 설정도 처리하나요?
아니요, 이 SKILL은 인프라가 별도로 관리된다는 가정하에 애플리케이션 구성과 Dockerfile 생성에 집중합니다.
Dockerfile 생성 과정에는 무엇이 포함되나요?
빌드에는 .NET SDK 이미지를 사용하고 최종 단계에는 .NET runtime 이미지를 사용하는 멀티 스테이지 Dockerfile을 생성합니다.