使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Firebase App Hosting
plat_web
Firebase App Hosting 可简化动态 Web 应用的开发和部署,提供 GitHub 集成,以及与 Authentication、Cloud Firestore 和 Firebase AI Logic 等其他 Firebase 产品的集成。
App Hosting 内置了对 Next.js 和 Angular 的预配置支持,并广泛支持各种热门 Web 框架。
开始
主要功能
GitHub 集成 |
只需进行一次 Git 提交,即可发布新版应用。
App Hosting 可以在每次您推送到特定分支时自动部署。
|
由 Google Cloud 提供支持 |
App Hosting 使用 Google Cloud 服务条款,并将您的应用部署到您信任的 Google Cloud 产品中。应用由 Cloud Build 构建,在 Cloud Run 上提供,并在 Cloud CDN 中缓存。
Cloud Secret Manager 等集成服务可确保 API 密钥安全无虞。
|
大规模交付 AI 赋能的功能 |
从使用 Gemini 的 AI 示例开始。
使用 Cloud Secret Manager 保护 API 端点的 API 密钥,并利用 App Hosting 的流式传输支持来保持较快的初始加载速度,即使您向应用中添加了生成式 AI 功能也是如此。
|
Firebase 控制台集成 |
在 Firebase 控制台中监控 build 和发布情况,以便随时了解最新动态。通过 Firebase 控制台访问日志和指标、添加自定义网域,以及手动触发发布。
|
工作原理
- 使用 Firebase 控制台或 Firebase CLI,在您的代码库中授权并安装 Firebase GitHub 应用。
- 仍在 Firebase 控制台或 Firebase CLI 中,创建一个 Firebase App Hosting 后端,其中包含用于持续部署的代码库和实时分支。
App Hosting 会为您的后端创建默认发布政策,以便在将更改推送到目标分支时立即发布到 100% 的流量。
- 当提交推送到您的实时分支时,Google Cloud Developer Connect 会向 Firebase App Hosting 发送事件。
- 响应此事件时,Firebase App Hosting 会为连接到代码库的后端创建新的 build。
- 首先,Firebase App Hosting 会为您的提交创建新的 Cloud Build build。在此作业中,Google Cloud buildpack 会确定您的应用中使用的框架,以创建适合您应用的容器和配置(包括环境变量、Secret、最小或最大实例数、并发内存、CPU 和 VPC 配置)。如需了解详情,请参阅App Hosting 构建流程。
- Cloud Build 作业完成后,您的容器将存储在专用于 Firebase App Hosting 的 Artifact Registry 代码库中。然后,Firebase App Hosting 使用您的映像和配置向 Cloud Run 服务添加新的 Cloud Run 修订版本。
- 当 Cloud Run 修订版本完成并验证为正常运行后,Firebase App Hosting 会修改其流量配置,以将所有新请求指向新的 Cloud Run 修订版本。至此,推出已完成。
- 当请求发送到托管在 Firebase App Hosting 上的网站时,该请求由启用了 Cloud CDN 的 Google Cloud 负载平衡器处理。未缓存的请求会发送到您的 Cloud Run 服务。
实现流程
|
设置 Firebase |
如果您还没有 Firebase 项目,请创建一个,并确保该项目已启用 Blaze 定价方案。
|
|
设置 App Hosting |
使用 Firebase 控制台或 Firebase CLI 创建 App Hosting 后端。这是应用的受管资源集合,包括与应用 GitHub 代码库的连接。
|
|
管理和监控应用 |
创建完 App Hosting 后端后,您的应用即可通过其免费子网域访问,并且您可以在 Firebase 控制台中查看有关发布过程的详细信息。您可以使用 Google Cloud 控制台查看和搜索日志。
|
|
开发应用 |
App Hosting 每次将提交推送到活动分支时,都会自动开始新的发布。
|
后续步骤
- 开始部署应用。
- 不妨尝试一个将托管应用与 Firebase Authentication 和 Google AI 功能集成的 App Hosting Codelab:Next.js | Angular。}
- 详细了解 App Hosting 支持的各种社区支持的框架。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[],[],null,["Firebase App Hosting \nplat_web \n\nFirebase App Hosting streamlines the development and deployment of dynamic\nweb apps, offering GitHub integration and integration with other Firebase\nproducts like Authentication, Cloud Firestore, and Firebase AI Logic.\nApp Hosting has built-in, preconfigured support for Next.js and Angular\nas well as broader support for various popular web frameworks.\n\n[Get started](/docs/app-hosting/get-started)\n\nKey capabilities\n\n|-----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| GitHub integration | A git commit is all that's needed to roll out a new version of your app. App Hosting can automatically deploy every time you push to a specific branch. |\n| Backed by Google Cloud | App Hosting uses Google Cloud Terms of Service, and deploys your app to Google Cloud products you trust. Apps are built with Cloud Build, served on Cloud Run, and cached in Cloud CDN. Integrated services like Cloud Secret Manager keep your API keys safe. |\n| Ship AI-powered features at scale | Start with AI samples that use Gemini. Protect your API endpoint's API key with Cloud Secret Manager and leverage App Hosting's streaming support to maintain fast initial load times as you add generative AI features into your app. |\n| Firebase console integration | Monitor your builds and rollouts in the Firebase console so you always know what's going on. Access logs and metrics, add a custom domain, and manually trigger rollouts from the Firebase console. |\n\nHow does it work?\n\n1. Using the Firebase console or Firebase CLI, authorize and install the Firebase GitHub app on your repository.\n2. Still in the Firebase console or Firebase CLI, create a Firebase App Hosting backend, with a repository and live branch for continuous deployment. App Hosting creates a default rollout policy for your backend to roll out to 100% of traffic immediately when a change is pushed to the target branch.\n3. When a commit is pushed to your live branch, Google Cloud Developer Connect sends an event to Firebase App Hosting.\n4. Responding to this event, Firebase App Hosting creates a new build for the backend connected to the repository.\n 1. First, Firebase App Hosting creates a new Cloud Build build for your commit. In this job, [Google Cloud buildpacks](https://cloud.google.com/docs/buildpacks/overview) determine which framework is being used in your application to create a container and configuration (including environment variables, secrets, minimum or maximum instances, concurrency memory, CPU, and VPC configuration) that suits your application. See [the App Hosting build process](/docs/app-hosting/build) For more information.\n 2. When the Cloud Build job is complete, your container is stored in an Artifact Registry repository dedicated to Firebase App Hosting. Firebase App Hosting then adds a new Cloud Run Revision to a Cloud Run service using your image and configuration.\n5. Once your Cloud Run Revision is complete and verified healthy, Firebase App Hosting modifies its traffic configuration to point all new requests to your new Cloud Run Revision. At this point, the rollout is complete.\n6. When a request is sent to a website hosted on Firebase App Hosting, the request is served by Google Cloud Load Balancer with Cloud CDN enabled. Uncached requests are sent to your Cloud Run service.\n\nImplementation path\n\n|---|-----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | Set up Firebase | If you don't already have one, create a Firebase project and make sure it has the Blaze pricing plan enabled. |\n| | Set up App Hosting | With the Firebase console or the Firebase CLI, create an App Hosting backend. This is the collection of managed resources for your app, including the connection to the GitHub repository for your app. |\n| | Manage and monitor your app | When you finish creating an App Hosting backend, your app is available on its free subdomain, and you can view details about the rollout in the Firebase console. You can use the [Google Cloud console](https://console.cloud.google.com/logs/query?project=_) to view and search through your logs. |\n| | Develop your app | App Hosting automatically starts a new rollout every time a commit is pushed to your live branch. |\n\nNext steps\n\n- [Get started](/docs/app-hosting/get-started) deploying apps.\n- Try an App Hosting codelab that integrates a hosted app with Firebase Authentication and Google AI features: [Next.js](https://firebase.google.com/codelabs/firebase-nextjs) \\| [Angular](https://firebase.google.com/codelabs/firebase-web).}\n- Learn more about the various [community-supported frameworks](https://firebaseopensource.com/platform/app_hosting) supported by App Hosting."]]