Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Firebase App Hosting sử dụng Cloud Build để chuyển đổi mã nguồn ứng dụng của bạn thành một định dạng đóng gói phù hợp để triển khai trên Cloud Run.
Quy trình tạo hoạt động thông qua các giai đoạn chính sau:
Nhập: Thu thập mã nguồn và cấu hình ứng dụng của bạn.
Build (Tạo): Cài đặt các phần phụ thuộc và tạo ứng dụng của bạn.
Handoff (Bàn giao): Hoàn tất vùng chứa Cloud Run sản xuất.
Ba bước này tương ứng trực tiếp với các bước 1, 2 và 3 của bản dựng như minh hoạ trong Cloud Build trong Bảng điều khiển Google Cloud:
Giai đoạn nhập
Giai đoạn này chịu trách nhiệm xử lý logic trước khi tạo. Thư viện này đọc, dọn dẹp và ghi các biến môi trường do người dùng xác định. Thư viện này cũng huỷ tham chiếu và ghim mọi bí mật được chỉ định trong tệp apphosting.yaml.
Giai đoạn xây dựng
Đây là cốt lõi của quy trình tạo bản dựng, chịu trách nhiệm tạo một hình ảnh vùng chứa có thể chạy và một tệp bundle.yaml xác định cấu hình bản dựng của bạn.
Công cụ này sử dụng Cloud Native Buildpacks để đóng gói ứng dụng một cách hiệu quả. Bạn có thể tìm thêm thông tin về tệp bundle.yaml trên github.
Buildpack chịu trách nhiệm chuyển đổi mã nguồn ứng dụng của bạn thành hình ảnh vùng chứa sẵn sàng cho sản xuất. Firebase App Hosting liên kết một số gói bản dựng với nhau để hoàn tất quy trình tạo bản dựng:
Runtime Buildpack: Đảm bảo rằng tất cả các thành phần cần thiết để chạy một ứng dụng Node.js cơ bản đều được đưa vào và các phần phụ thuộc đều được cài đặt.
Monorepo Buildpack: Định cấu hình các gói bản dựng tiếp theo để xử lý các tình huống monorepo khác nhau.
Framework Buildpack: Cài đặt bộ chuyển đổi khung hình phù hợp (chẳng hạn như Angular hoặc Next.js) và chuẩn bị các buildpack tiếp theo.
Bộ chuyển đổi khung chịu trách nhiệm chạy lệnh tạo bản dựng được sản xuất và ánh xạ mọi giá trị cấu hình cụ thể của khung có liên quan sang định dạng tiêu chuẩn mà App Hosting có thể đọc được.
Package Manager Buildpack: Thực thi quá trình cài đặt các phần phụ thuộc và tạo ứng dụng bằng npm, yarn hoặc pnpm.
Gói bản dựng đầu ra: Xác định lệnh chạy và chuẩn bị gói đầu ra để thực thi.
Giai đoạn chuyển giao
Giai đoạn cuối cùng này đóng gói tất cả thông tin được trích xuất từ mã nguồn ứng dụng cùng với hình ảnh vùng chứa bản dựng và gửi đến phần phụ trợ App Hosting. Sau đó, phần phụ trợ App Hosting sẽ sử dụng thông tin này để thiết lập Cloud Run với cấu hình phù hợp.
Tìm hiểu thêm
Toàn bộ quy trình tạo App Hosting đều là nguồn mở.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[],[],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)"]]