App Hosting 建構程序
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Firebase App Hosting 會使用 Cloud Build 將應用程式原始碼轉換為容器化格式,以便部署至 Cloud Run。
建構程序會經歷下列主要階段:
擷取:收集應用程式原始碼和設定。
建構:安裝依附元件並建構應用程式。
交接:完成製作 Cloud Run 容器。
這三個步驟直接對應至 Google Cloud 控制台中顯示的建構步驟 1、2 和 3:Cloud Build

擷取階段
這個階段負責處理建構前邏輯。這個函式會讀取、清除及寫入使用者定義的環境變數。此外,也會取消參照並釘選 apphosting.yaml
檔案中指定的任何密鑰。
建構階段
這是建構程序的核心,負責產生可執行的容器映像檔,以及定義建構設定的 bundle.yaml
檔案。這項工具會使用 Cloud Native Buildpacks,有效率地封裝應用程式。如要進一步瞭解 bundle.yaml
檔案,請前往 github。
Buildpacks 負責將應用程式原始碼轉換為可立即用於實際工作環境的容器映像檔。Firebase App Hosting 會將多個建構包串連在一起,完成建構程序:
- 執行階段建構包:確保包含執行基本 Node.js 應用程式所需的所有元件,並安裝依附元件。
- Monorepo Buildpack:設定後續的建構套件,處理不同的 Monorepo 情境。
架構 Buildpack:安裝正確的架構介面卡 (例如 Angular 或 Next.js),並準備後續的 Buildpack。
架構轉接程式負責執行正式版建構指令,並將所有相關的架構專屬設定值對應至 App Hosting 可讀取的標準格式。
套件管理員 Buildpack:使用 npm、yarn 或 pnpm 執行依附元件安裝作業,並建構應用程式。
輸出套裝組合建構包:定義執行指令,並準備要執行的輸出套裝組合。
交接階段
最後一個階段會將從應用程式原始碼擷取的所有資訊,以及建構容器映像檔打包,然後傳送至後端。App HostingApp Hosting 後端接著會使用這項資訊,以適當的設定建立 Cloud Run。
瞭解詳情
整個App Hosting建構程序都是開放原始碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[],[],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)"]]