App Hosting 构建流程
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Firebase App Hosting 利用 Cloud Build 将应用源代码转换为适合在 Cloud Run 上部署的容器化格式。
构建过程通过以下关键阶段运行:
提取:收集应用源代码和配置。
Build:安装依赖项并构建应用。
交付:最终确定生产 Cloud Run 容器。
这三个步骤直接对应于 Google Cloud 控制台中 Cloud Build 中显示的构建步骤 1、2 和 3:

提取阶段
此阶段负责处理预构建逻辑。它会读取、清理和写入用户定义的环境变量。它还会取消引用并固定 apphosting.yaml
文件中指定的任何密钥。
构建阶段
这是构建流程的核心,负责生成可运行的容器映像以及定义构建配置的 bundle.yaml
文件。它利用 Cloud Native Buildpack 高效地封装应用。如需详细了解 bundle.yaml
文件,请访问 github。
Buildpack 负责将应用源代码转换为可用于生产用途的容器映像。Firebase App Hosting 将多个 buildpack 链接在一起,以完成 build 流程:
- 运行时 buildpack:确保包含运行基本 Node.js 应用所需的所有组件,并安装依赖项。
- Monorepo Buildpack:配置后续 buildpack 以处理不同的 monorepo 场景。
框架 Buildpack:安装正确的框架适配器(例如 Angular 或 Next.js),并准备后续的 buildpack。
框架适配器负责运行已投入生产的 build 命令,并将任何相关的框架特定配置值映射到 App Hosting 可读取的标准格式。
软件包管理器 Buildpack:使用 npm、yarn 或 pnpm 执行依赖项安装并构建应用。
输出软件包 buildpack:定义运行命令并准备输出软件包以供执行。
交接阶段
此最终阶段会将从应用源代码中提取的所有信息以及构建容器映像打包,并将其发送到 App Hosting后端。然后,App Hosting 后端会使用此信息设置具有适当配置的 Cloud Run。
了解详情
整个 App Hosting 构建流程都是开源的。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[],[],null,["\u003cbr /\u003e\n\nFirebase App Hosting utilizes Cloud Build to transform your\napplication source code into a containerized format suitable for deployment on\nCloud Run.\n\nThe build process operates through the following key stages:\n\n1. **Ingest**: Gathers your application source code and configuration.\n\n2. **Build**: Installs dependencies and builds your application.\n\n3. **Handoff** : Finalizes the production Cloud Run container.\n\nThese three steps correspond directly to build steps 1, 2 and 3 as displayed in\nCloud Build in the Google Cloud Console:\n\nIngest stage\n\nThis stage is responsible for handling pre-build logic. It reads, sanitizes, and\nwrites user-defined environment variables. It also dereferences and pins any\nsecrets specified in the `apphosting.yaml` file.\n\nBuild stage\n\nThis is the core of the build process, responsible for generating a runnable\ncontainer image and a `bundle.yaml` file defining your build configuration.\nIt utilizes [Cloud Native Buildpacks](https://cloud.google.com/docs/buildpacks/overview)\nto package the\napplication efficiently. More information on the `bundle.yaml`file can be found\non [github](https://github.com/FirebaseExtended/firebase-framework-tools).\n\nBuildpacks are responsible for transforming your application source code into\nproduction ready container images. Firebase App Hosting chains together\nseveral buildpacks to complete the build process:\n\n1. **Runtime Buildpack**: Ensures all necessary components for running a basic Node.js application are included and dependencies are installed.\n2. **Monorepo Buildpack**: Configures subsequent buildpacks to handle different monorepo scenarios.\n3. **Framework Buildpack**: Installs the correct framework adapter (like\n Angular or Next.js) and prepares subsequent buildpacks.\n\n Framework adapters are in charge of running the productionized build\n command and mapping any relevant framework-specific config values to a\n standard format readable by App Hosting.\n4. **Package Manager Buildpack**: Executes the installation of dependencies and\n builds the app using npm, yarn, or pnpm.\n\n5. **Output Bundle Buildpack**: Defines the run command and prepares the output\n bundle for execution.\n\nHandoff stage\n\nThis final stage packages all the information extracted from the application\nsource code plus the build container image and sends it to the App Hosting\nbackend. The App Hosting backend then uses this information to set up\nCloud Run with the proper configurations.\n\nLearn more\n\nThe entire App Hosting build process is open source.\n\n- The buildpack code is in [the Google Cloud buildpacks repo](https://github.com/GoogleCloudPlatform/buildpacks)\n- Code for framework adapters is in the [firebase-framework-tools repo](https://github.com/FirebaseExtended/firebase-framework-tools)\n- Learn more about [Cloud Native buildpacks](https://cloud.google.com/docs/buildpacks/overview) and [Cloud Build](https://cloud.google.com/build/docs/overview)"]]