philips-software/amp-devcontainer

GitHub: philips-software/amp-devcontainer

面向嵌入式 C++ 和 Rust 开发的预配置开发容器镜像,整合编译、测试、安全扫描等工具链,支持本地与 CI 环境一致性。

Stars: 132 | Forks: 7

# amp-devcontainer [![Linting & Formatting](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/93192a17ef015013.svg)](https://github.com/philips-software/amp-devcontainer/actions/workflows/linting-formatting.yml) [![Continuous Integration](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/86731bc10c015015.svg)](https://github.com/philips-software/amp-devcontainer/actions/workflows/continuous-integration.yml) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/9267/badge)](https://www.bestpractices.dev/projects/9267) [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/philips-software/amp-devcontainer/badge)](https://securityscorecards.dev/viewer/?uri=github.com/philips-software/amp-devcontainer) ## 目录 - [概述](#overview) - [状态](#state) - [描述](#description) - [镜像版本](#image-flavors) - [版本控制](#versioning) - [Visual Studio Code](#visual-studio-code) - [使用方法](#usage) - [验证镜像签名](#verify-image-signature) - [本地开发](#local-development) - [持续集成](#continuous-integration) - [社区](#community) - [更新日志](#changelog) - [贡献](#contributing) - [报告漏洞](#reporting-vulnerabilities) - [许可证](#licenses) ## 概述 此仓库包含专为现代嵌入式软件开发量身定制的 [devcontainers](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)。 ### 关键特性 - **开箱即用** 🔋:为本地开发和持续集成预配置的工具。 - **开发者体验** 👩‍💻:极简的设置时间和最大化的“左移”策略。 - **多平台支持** ⚙️:兼容 Windows、Linux 和 macOS 上的 x64 和 arm64 硬件。 - **镜像版本** 🍨:专用于 C++ 和 Rust 开发的专用容器。 - **IDE 集成** 💻:完全兼容 GitHub Codespaces 和 VS Code。 - **语义化版本控制** 🔢:清晰的容器镜像版本控制策略。 - **安全** 🔒:强调供应链安全并兼容 Dependabot。 - **经过测试** ✅:包含验证测试。 这些容器试图在不带过多主观色彩的前提下尽可能做到“开箱即用”,既可用于本地开发,也可用于持续集成。 所有容器都是多平台的,可在支持 [OCI](https://opencontainers.org/) 兼容容器引擎的操作系统上使用 x64 (x86-64) 和 arm64 硬件。 这包括 Intel 和 Apple 芯片上的 Windows、Linux 和 macOS。 ## 状态 此仓库正在积极开发中;有关更多详细信息,请参阅 [pulse](https://github.com/philips-software/amp-devcontainer/pulse)。 ## 描述 ### 镜像版本 以下 devcontainers 发布在 [GitHub Container Registry](https://ghcr.io/) 上: - [amp-devcontainer-base](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-base);其他版本使用的共享基础镜像 - [amp-devcontainer-cpp](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-cpp);C++ 容器 - [amp-devcontainer-rust](https://github.com/orgs/philips-software/packages/container/package/amp-devcontainer-rust);Rust 容器 所有容器都包含完整的 [Visual Studio Code](https://code.visualstudio.com/) 配置,且兼容 [GitHub Codespaces](https://github.com/features/codespaces)。 下方汇总了包含的工具。 有关所有包含的工具和工具版本的完整列表,请参阅 [Dependency Graph](https://github.com/philips-software/amp-devcontainer/network/dependencies)、随 [release](https://github.com/philips-software/amp-devcontainer/releases) 发布的 SBOM,或附加到镜像的 SBOM。 #### amp-devcontainer-base amp-devcontainer-base 镜像是其他版本使用的共享基础。 它整合了通用工具(例如证书和测试工具),以便版本镜像可以专注于特定语言的功能。 #### amp-devcontainer-cpp 基于此仓库构建的 amp-devcontainer-cpp 包含编译器和工具,以促进现代嵌入式 C++ 开发。 amp-devcontainer-cpp 支持使用 gcc、arm-gcc 和 clang 编译器进行主机编译和交叉编译。 除了编译器外,还支持包管理(使用 [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) 和 [Conan](https://conan.io/))、代码覆盖率测量、变异测试(使用 [mull](https://github.com/mull-project/mull))、模糊测试(使用 [libfuzzer](https://www.llvm.org/docs/LibFuzzer.html))以及静态分析和格式化(clang-format、clang-tidy、clangd、include-what-you-use)。 默认构建系统设置为使用 CMake、Ninja 和 CCache。 #### amp-devcontainer-rust 基于此仓库构建的 amp-devcontainer-rust 包含 Rust 生态系统和额外的工具,以促进嵌入式 Rust 开发。 amp-devcontainer-rust 支持主机编译和交叉编译。 除了 Rust 生态系统外,还支持代码覆盖率测量、变异测试(使用 [cargo-mutants](https://mutants.rs/))、模糊测试(使用 [rust-fuzz](https://rust-fuzz.github.io/book/introduction.html))以及静态分析和格式化(clippy、rustfmt)。 用于嵌入式开发以及烧录和调试的 [probe-rs](https://probe.rs/) 和 [flip-link](https://github.com/knurling-rs/flip-link) 也包含在内。 ### 版本控制 amp-devcontainer 仓库对其容器镜像遵循 [语义化版本控制](https://semver.org/spec/v2.0.0.html) 策略。 这确保了更新和兼容性的清晰沟通。 使用的版本格式为 `..`。 发布的容器标记为 ``、`.`、`..` 和 `v..`。 默认分支上的最新构建标记为 `edge`,拉取请求构建标记为 `pr-`。 | Branch | Tag | |--------------|----------------------------| | Default | `edge` | | Pull Request | `pr-` | | Release | `v..` | | | `..` | | | `.` | | | `` | 发布的容器永远不会被清理,拉取请求构建在拉取请求关闭时会被清理,而 edge 构建将在发布新的 edge 版本后不久被清理。 发布说明始终包含相应镜像版本的概述,其中包含版本号旁边的完整 SHA。 这使得人类可以轻松查看所使用的版本,同时仍固定到确切版本。 这是引用镜像的推荐方式。 所有容器镜像都包含在一个版本中。 将来如果需要为每个容器单独发布版本,这种情况可能会改变。 此版本控制策略作为 GitHub Actions 工作流实施,确保各版本的一致性和安全性。 只有 GitHub Action 工作流被允许创建版本,生成的镜像是[已签名](#verify-image-signature)的。 ### Visual Studio Code 所有容器都可以在 Visual Studio Code 或 GitHub Codespaces 中使用,无需任何额外配置。 所有包含的工具都已预配置,必要的插件将在容器启动时安装。 此行为是通过根据这些[规范](https://containers.dev/implementors/reference/#labels)将 devcontainer 元数据附加到镜像标签来实现的。 可以按照此[合并逻辑](https://containers.dev/implementors/spec/#merge-logic)覆盖、补充或更改选项。 ## 使用方法 本章介绍如何在两个常见用例中使用 amp-devcontainer,并详细介绍如何验证容器镜像的签名。 ### 验证镜像签名
5.6.0 版本之前 容器镜像使用 [SigStore](https://www.sigstore.dev/) [Cosign](https://docs.sigstore.dev/cosign/signing/overview/) 通过无密钥签名方法进行签名。 可以使用以下命令(使用 Docker)[验证](https://docs.sigstore.dev/cosign/verifying/verify/)签名,以验证镜像确实由 GitHub CI 系统签名: ``` docker run --rm gcr.io/projectsigstore/cosign verify ghcr.io/philips-software/amp-devcontainer-<🍨 flavor> --certificate-oidc-issuer https://token.actions.githubusercontent.com --certificate-identity-regexp https://github.com/philips-software/amp-devcontainer ```
容器镜像使用 [attest-build-provenance](https://github.com/actions/attest-build-provenance) 操作进行签名。 可以使用以下命令检查证明,以验证镜像确实由 GitHub CI 系统构建: ``` gh attestation verify --repo philips-software/amp-devcontainer oci://ghcr.io/philips-software/amp-devcontainer-<🍨 flavor> ``` ### 本地开发 生成的容器可在 `.devcontainer.json` 文件或 `.devcontainer` 文件夹中使用。 ``` { "image": "ghcr.io/philips-software/amp-devcontainer-<🍨 flavor>:latest" } ``` ### 持续集成 生成的容器可以通过使用作业上的 [`container`](https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container) 属性在 GitHub 工作流中使用。 ``` jobs: container-job: runs-on: ubuntu-latest container: ghcr.io/philips-software/amp-devcontainer-<🍨 flavor>:latest ``` ## 更新日志 有关更改内容的更多信息,请参阅 [changelog](./CHANGELOG.md)。 ### 构建与测试 [![Open in Dev Containers](https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/philips-software/amp-devcontainer) 如果您已经安装了 VS Code 和 OCI 兼容的容器引擎,可以点击上方的徽章或[此处](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/philips-software/amp-devcontainer)开始。点击这些链接将导致 VS Code 在需要时自动安装 Dev Containers 扩展,将源代码克隆到容器卷中,并启动开发容器以供使用。或者也可以启动 GitHub Codespace。 #### 运行集成测试 从测试资源管理器运行包含的 `bats` 集成测试。或者使用 Ctrl + ; A 运行所有测试。 #### 运行验收测试 在工作区的根目录下创建一个包含以下内容的 .env 文件,此处假设有一个 GitHub 帐户,该帐户有权在此仓库上创建 Codespace,并配置了基于时间的一次性密码 (TOTP) 双重认证 (2FA)。 ``` GITHUB_USER= GITHUB_PASSWORD= GITHUB_TOTP_SECRET= ``` 现在可以使用测试资源管理器运行测试。默认情况下,用户界面在端口 6080 上可用。当端口 6080 已被占用时,将暴露另一个端口。可以通过端口视图查看这一点(Ctrl + Shift + P,Ports: Focus on Ports View)。 ## 报告漏洞 如果您发现漏洞,请向我们报告! 有关更多信息,请参阅 [security](.github/SECURITY.md)。 ## 许可证 amp-devcontainer 是在 MIT 许可证下授权的。 有关更多信息,请参阅 [license](./LICENSE)。
标签:Bash脚本, Batteries-included, DevContainer, DevEx, Docker, GitHub Codespaces, NIDS, PyVis, VS Code, 可视化界面, 安全防御评估, 容器化, 嵌入式开发, 开发容器, 开发工具箱, 开发环境, 开发者体验, 开源, 开源框架, 持续集成, 数据管道, 最佳实践, 现代软件开发, 请求拦截, 软件工程, 镜像构建