跳到正文
Skillpedia
部署与云(DevOps)40k · #7117

containerize-aspnetcore

它能做什么

这个工具会生成把你的 ASP.NET Core 项目变成“容器”所需的指令(称为 Dockerfile)。容器就像一个隔离的打包盒,里面装着应用运行所需的一切,让它更容易部署到不同的环境中。

适用场景

  • ✓当你想在服务器上运行 ASP.NET Core 应用,又不想手动安装各种依赖时。
  • ✓当你准备把应用部署到云端时(比如 Azure、AWS、Google Cloud)。
  • ✓当你需要确保应用在任何电脑上都能以相同方式运行时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/containerize-aspnetcore/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/containerize-aspnetcore/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请为我的 ASP.NET Core 项目 'my-project/my-app.csproj' 创建容器,使用 .NET 8 和 Alpine Linux 发行版。”

每周 5 个新技能,1 分钟读完。

工作原理

工具会分析你提供的设置,比如 .NET 版本和想要的 Linux 类型。基于这些信息,它会生成一个名为 Dockerfile 的文件,它就是构建你应用容器的分步指南。

技术内容(原始 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

  1. Project to containerize:

    • [ProjectName (provide path to .csproj file)]
  2. .NET version to use:

    • [8.0 or 9.0 (Default 8.0)]
  3. Linux distribution to use:

    • [debian, alpine, ubuntu, chiseled, or Azure Linux (mariner) (Default debian)]
  4. 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)]
  5. 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

  1. Ports that must be exposed in the container image:

    • Primary HTTP port: [e.g., 8080]
    • Additional ports: [List any additional ports, or "None"]
  2. User account the container should run as:

    • [User account, or default to "$APP_UID"]
  3. Application URL configuration:

    • [Specify ASPNETCORE_URLS, or default to "http://+:8080"]

Build configuration

  1. Custom build steps that must be performed before building the container image:

    • [List any specific build steps, or "None"]
  2. Custom build steps that must be performed after building the container image:

    • [List any specific build steps, or "None"]
  3. NuGet package sources that must be configured:

    • [List any private NuGet feeds with authentication details, or "None"]

Dependencies

  1. System packages that must be installed in the container image:

    • [Package names for the chosen Linux distribution, or "None"]
  2. Native libraries that must be copied to the container image:

    • [Library names and paths, or "None"]
  3. Additional .NET tools that must be installed:

    • [Tool names and versions, or "None"]

System Configuration

  1. Environment variables that must be set in the container image:
    • [Variable names and values, or "Use defaults"]

File System

  1. 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"]
  2. Files/directories to exclude from containerization:

    • [Paths to exclude, or "None"]
  3. Volume mount points that should be configured:

    • [Volume paths for persistent data, or "None"]

.dockerignore Configuration

  1. Patterns to include in the .dockerignore file (.dockerignore will already have common defaults; these are additional patterns):
    • Additional patterns: [List any additional patterns, or "None"]

Health Check Configuration

  1. Health check endpoint:

    • [Health check URL path, or "None"]
  2. Health check interval and timeout:

    • [Interval and timeout values, or "Use defaults"]

Additional Instructions

  1. Other instructions that must be followed to containerize the project:

    • [Specific requirements, or "None"]
  2. 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))

…

常见问题

什么是容器?

可以把容器想象成一个标准化的盒子,里面包含你的应用以及它运行所需的一切(代码、库、设置)。这样它就能在任何地方一致地运行。

什么是 Dockerfile?

它是一个文本文件,里面写着 Docker(容器技术)构建容器镜像时要遵循的指令。可以把它看作用来打包你应用的“配方”。

使用这个工具需要很懂 Docker 吗?

不需要。这个工具隐藏了大部分复杂性,你只需要填写项目的基本设置,就能创建容器。

详情

作者的原始描述

Containerize an ASP.NET Core project by creating Dockerfile and .dockerfile files customized for the project.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7117
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能