Amazon Q Developer 中的範例 devfile - Amazon Q Developer

Amazon Q Developer 中的範例 devfile

下列範例顯示符合 devfile 規格且適合搭配 Amazon Q 使用的 devfile。範例將在本頁最後加以說明。

如需有關 devfile 及其在 Amazon Q 中使用方式的詳細資訊,請參閱 測試 Amazon Q '/dev' 命令產生的程式碼建議

Python 範例

下列範例顯示可搭配 Python 專案使用的 devfile。

schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: "pip3.11 install -r requirements.txt" - id: test exec: component: dev commandLine: "python3.11 manage.py makemigrations && python3.11 manage.py test"

Node 範例

下列範例顯示可搭配 Node.js 專案使用的 devfile。

schemaVersion: 2.0.0 components: - name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest commands: - id: install exec: component: dev commandLine: "npm install" - id: build exec: component: dev commandLine: "npm run build" - id: test exec: component: dev commandLine: "npm run test"

範例說明

下表說明上述 devfile 範例中的每一行或程式碼區塊。

行或程式碼區塊 描述
schemaVersion: 2.0.0

指定 devfile 結構描述版本。Amazon Q 僅支援結構描述 2.0.0 版

components:

要部署到開發環境的元件清單。

- name: dev container: image: public.ecr.aws/aws-mde/universal-image:latest

指出,使用公有 Amazon Elastic Container Registry (Amazon ECR) 中提供的最新通用映像 Docker 映像檔作為開發環境。您可以變更此映像檔的版本,也可以將映像檔取代為您自己的映像檔。如需詳細資訊,請參閱 通用映像內容

commands:

要執行的命令清單。

- id: install|build|test exec: component: dev commandLine: "cli-instructions"

installbuildtest 命令。Amazon Q 會在開發環境中,於通用映像 (或 image: 中指定的任何映像檔) 上執行 cli-instructions 指令。cli-instructions 會隨著專案內容而有所不同。您可以變更這些命令以符合您的需求。