Communitygithub.com

microsoft/aspire.dev

從 microsoft/aspire 原始碼中提取所有容器映像參考(註冊表、映像、標籤),並為 aspire.dev Astro 網站生成 JSON 資料檔案。

aspire.dev 是什麼?

此技能旨在從 microsoft/aspire 產品儲存庫中萃取所有容器映像參考,並將其寫入至 microsoft/aspire.dev 儲存庫中的結構化 JSON 檔案。此 JSON 檔案供 aspire.dev 網站的 Astro 元件使用,用於呈現 Aspire 託管整合所使用的所有容器映像的可瀏覽目錄。技能會自動發現並解析原始碼中符合 `*ContainerImageTags.cs` 模式的靜態類別檔案,從中提取註冊表、映像、標籤等資訊,並處理主要映像與輔助映像(例如 pgAdmin、Kafka UI 等)的區分。此外也支援 `const` 與 `static` 屬性兩種模式,並能解析字串插值計算的標籤值。支援平台為 bash 命令列及檔案讀寫操作。此技能特別適用於更新容器映像 JSON、同步容器映像版本、列出所有 Aspire 容器映像等任務,但不應用於直接修改 Aspire 原始碼中的容器映像版本,也不應用於處理 NuGet 套件資料或開發容器的 Dockerfile 映像。對於單一映像標籤的快速查詢,建議改使用 grep/find 指令。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/microsoft/aspire.dev/tree/HEAD/.agents/skills/container-images

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

容器映像技能

此技能從 microsoft/aspire 產品儲存庫中萃取每一個容器映像參考,並將結構化 JSON 檔案寫入至 microsoft/aspire.dev 的以下位置:

src/frontend/src/data/container-images.json

此 JSON 檔案由 aspire.dev 網站的 Astro 元件使用,以呈現 Aspire 託管整合所使用的所有容器映像的可瀏覽目錄。


原始碼模式

microsoft/aspire 中的所有容器映像中繼資料都位於名稱格式為 *ContainerImageTags(或 *ContainerImageTags.cs)的靜態類別中。每個檔案都遵循嚴格且一致的模式:

internal static class <Name>ContainerImageTags
{
    public const string Registry = "<registry-host>";
    public const string Image = "<image-path>";
    public const string Tag = "<tag>";

    // 某些檔案還有額外的輔助映像,例如:
    public const string <Companion>Registry = "<registry-host>";
    public const string <Companion>Image = "<image-path>";
    public const string <Companion>Tag = "<tag>";
}

如何找到它們

所有符合以下 Glob 模式的檔案:

src/**/ContainerImageTags.cs
src/**/*ContainerImageTags.cs

這些檔案遍佈許多專案,包括(但不限於):

專案檔案
Aspire.Hosting.RedisRedisContainerImageTags.cs
Aspire.Hosting.PostgreSQLPostgresContainerImageTags.cs
Aspire.Hosting.SqlServerSqlServerContainerImageTags.cs
Aspire.Hosting.MongoDBMongoDBContainerImageTags.cs
Aspire.Hosting.MySqlMySqlContainerImageTags.cs
Aspire.Hosting.KafkaKafkaContainerImageTags.cs
Aspire.Hosting.RabbitMQRabbitMQContainerImageTags.cs
Aspire.Hosting.NatsNatsContainerImageTags.cs
Aspire.Hosting.GarnetGarnetContainerImageTags.cs
Aspire.Hosting.ValkeyValkeyContainerImageTags.cs
Aspire.Hosting.SeqSeqContainerImageTags.cs
Aspire.Hosting.QdrantQdrantContainerImageTags.cs
Aspire.Hosting.KeycloakKeycloakContainerImageTags.cs
Aspire.Hosting.OracleOracleContainerImageTags.cs
Aspire.Hosting.MilvusMilvusContainerImageTags.cs
Aspire.Hosting.ElasticsearchElasticsearchContainerImageTags.cs
Aspire.Hosting.YarpYarpContainerImageTags.cs
Aspire.Hosting.Azure.StorageStorageEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.CosmosDBCosmosDBEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.ServiceBusServiceBusEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.EventHubsEventHubsEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.SignalRSignalREmulatorContainerImageTags.cs
Aspire.Hosting.Azure.AppConfigurationAppConfigurationEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.FunctionsDurableTaskSchedulerEmulatorContainerImageTags.cs
Aspire.Hosting.Azure.KustoAzureKustoEmulatorContainerImageTags.cs

重要: 新的託管套件可能隨時新增。請務必動態發現檔案 — 切勿依賴硬編碼清單。


提取步驟

步驟 1 — 複製或存取 aspire 儲存庫的最新版本

# 若在本機環境中執行:
git clone --depth 1 https://github.com/microsoft/aspire.git /tmp/aspire

步驟 2 — 尋找所有 ContainerImageTags 檔案

find /tmp/aspire/src -name '*ContainerImageTags.cs' -type f

步驟 3 — 解析每個檔案

對於每個檔案,提取所有映像組。單一檔案可以定義多個映像(主要 + 輔助)。解析規則如下:

  1. 主要映像:欄位名稱恰好為 Registry、Image、Tag。
  2. 輔助映像:帶有前綴的欄位,例如 PgAdminRegistry、PgAdminImage、PgAdminTag — 依共享的前綴分組。
  3. 替代標籤:例如 TagVNextPreview、ManagementTag — 將這些作為同一映像的附加標籤變體包含在內。
  4. 靜態屬性 vs. const 欄位:大多數使用 public const string,但有些(例如 Kusto)使用 public static string { get; }。兩種模式都要處理。
  5. 計算標籤:某些標籤是計算出來的,例如 public const string ManagementTag = $"{Tag}-management"; — 需將其解析為字面值。
  6. 推導 aspirePackage:從專案目錄名稱取得(例如 src/Aspire.Hosting.Redis/ → Aspire.Hosting.Redis)。
  7. 推導 sourceFile:相對於儲存庫根目錄的路徑。

步驟 4 — 建立 JSON

輸出陣列中的每個條目代表一個不同的容器映像:

[
  {
    "aspirePackage": "Aspire.Hosting.Redis",
    "name": "Redis",
    "registry": "docker.io",
    "image": "library/redis",
    "tag": "8.6",
    "fullImage": "docker.io/library/redis:8.6",
    "sourceFile": "src/Aspire.Hosting.Redis/RedisContainerImageTags.cs",
    "sourceUrl": "https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting.Redis/RedisContainerImageTags.cs",
    "isCompanion": false,
    "companionOf": null,
    "alternateTags": []
  },
  {
    "aspirePackage": "Aspire.Hosting.Redis",
    "name": "Redis Commander",
    "registry": "docker.io",
    "image": "rediscommander/redis-commander",
    "tag": "latest",
    "fullImage": "docker.io/rediscommander/redis-commander:latest",
    "sourceFile": "src/Aspire.Hosting.Redis/RedisContainerImageTags.cs",
    "sourceUrl": "https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting.Redis/RedisContainerImageTags.cs",
    "isCompanion": true,
    "companionOf": "Redis",
    "alternateTags": []
  },
  {
    "aspirePackage": "Aspire.Hosting.Azure.CosmosDB",
    "name": "CosmosDB Emulator",
    "registry": "mcr.microsoft.com",
    "image": "cosmosdb/linux/azure-cosmos-emulator",
    "tag": "stable",
    "fullImage": "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:stable",
    "sourceFile": "src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs",
    "sourceUrl": "https://github.com/microsoft/aspire/blob/main/src/Aspire.Hosting.Azure.CosmosDB/CosmosDBEmulatorContainerImageTags.cs",
    "isCompanion": false,
    "companionOf": null,
    "alternateTags": ["vnext-preview"]
  }
]

欄位定義

欄位類型說明
aspirePackagestringNuGet 套件/專案名稱(src/ 下的目錄名稱)
namestring易讀的名稱。對於主要映像,從類別名稱推導(移除 ContainerImageTags / EmulatorContainerImageTags 後綴,依 PascalCase 拆分)。對於輔助映像,根據輔助前綴/類型(例如 PgAdmin*、RedisCommander*)而非僅從類別名稱推導。
registrystring容器註冊表主機(例如 docker.io、mcr.microsoft.com、ghcr.io、quay.io、container-registry.oracle.com)
imagestring註冊表中的映像路徑
tagstring主要標籤
fullImagestring完整的映像參考:{registry}/{image}:{tag}
sourceFilestring相對於 microsoft/aspire 的原始碼檔案路徑
sourceUrlstring原始碼檔案在 main 分支上的 GitHub 永久連結
isCompanionboolean若為輔助/工具映像(例如 pgAdmin、Kafka UI、phpMyAdmin)則為 true
companionOfstring?此映像所輔助的主要映像名稱,若無則為 null
alternateTagsstring[]為此映像定義的任何其他標籤常數(例如 vnext-preview、management)

步驟 5 — 排序與寫入

按 aspirePackage(升冪)、isCompanion(主要優先)、name(升冪)排序。

寫入至:src/frontend/src/data/container-images.json


驗證檢查清單

產生檔案後,請確認:

  • src/ 中的每個 *ContainerImageTags.cs 檔案都已呈現
  • 沒有重複條目(相同的 registry + image + tag + aspirePackage)
  • 所有 fullImage 值格式正確(registry/image:tag)
  • 輔助映像正確連結至其主要映像
  • JSON 有效且格式正確(2 空格縮排)
  • 檔案已根據上述規則排序

在 Astro 中使用資料

位於 src/frontend/src/data/container-images.json 的 JSON 檔案可在 Astro 元件中直接匯入:

import containerImages from '../data/container-images.json';

這遵循與同一目錄中的現有資料檔案(例如 aspire-integrations.json、samples.json、github-stats.json)相同的模式。

連結相關內容

每個容器映像條目可與以下內容交叉參照:

  • 整合文件:位於 src/frontend/src/data/integration-docs.json(以 aspirePackage 匹配)
  • NuGet 整合:位於 src/frontend/src/data/aspire-integrations.json(以 title ≈ aspirePackage 匹配)
  • 原始碼檔案:連結回 microsoft/aspire 供貢獻者使用

重要規則

  • 務必動態發現檔案 — 新的託管套件會頻繁新增。
  • 同時解析 const 和 static 屬性模式 — 程式碼庫中兩者皆有。
  • 解析計算標籤值中的字串插值(例如 $"{Tag}-management")。
  • 不要包含 devcontainer 映像、僅用於測試的映像或 playground/ 目錄中的映像。
  • 僅從 src/ 目錄中提取符合 *ContainerImageTags.cs 的檔案。
  • aspire.dev 儲存庫是 Astro 網站 — 資料檔案與其他由元件使用的 JSON 資料放在一起。

相關技能