النشر من المصدر باستخدام واجهة سطر الأوامر Firebase
تتيح لك واجهة سطر الأوامر (CLI) في Firebase إرسال رمز المصدر وإعدادات تطبيقك مباشرةً من جهازك إلى Firebase. ويكون ذلك مناسبًا إذا كان لديك عمليات نشر أخرى في Firebase (مثل قواعد الأمان أو الدوال) وأردت نشر تطبيق الويب وخدمات الخلفية معًا باستخدام أمر واحد من واجهة سطر الأوامر.
عند النشر، تحمّل App Hosting الرمز المصدر إلى حزمة Google Cloud Storage، وتنفّذ أمر إنشاء إطار العمل في Cloud Build، وتنشر النتائج النهائية إلى Cloud Run وCloud CDN. تستخدم App Hostingعملية الإنشاء نفسها لعمليات نشر المصدر المحلية كما هو الحال في عمليات النشر على GitHub. إذا كان لديك ملف .gitignore في مشروعك، سيتم استبعاد الملفات والمجلدات المدرَجة فيه من عملية النشر.
لنشر تطبيقك من مصدر محلي، اتّبِع الخطوات التالية:
نفِّذ الأمر firebase init apphosting في دليل مشروعك المحلي.
عند ظهور الطلب، اختَر استخدام مشروع حالي، ثم اختَر مشروع Firebase الذي اخترته.
اختَر إما نظامًا خلفيًا جديدًا أو حاليًا لنشره. وتعمل هذه الخطوة على إعداد عمليات نشر App Hosting لدليلك المحلي، وتطلب منك المعلومات التي تحتاجها App Hosting لنشر تطبيقك بنجاح:
رقم تعريف الخلفية التي سيتم نشرها
المنطقة التي سيتم النشر فيها (في حال إنشاء خلفية جديدة)
مسار الدليل الجذر لرمز التطبيق
تحفظ App Hosting إعدادات النشر المفضّلة في firebase.json (يتم إنشاء الملف في مشروعك المحلي إذا لم يكن متوفّرًا). بعد اكتمال عملية الإعداد بنجاح، يمكنك تشغيل firebase deploy لنشر الرمز المصدر إلى App Hosting.
إذا كانت لديك عمليات نشر مصدر محلّي تم إعدادها لخوادم خلفية متعددة (ما يعني أنّ هناك إدخالات backendId متعددة في firebase.json)، سيتم نشر firebase deploy على كل خادم من هذه الخوادم الخلفية. للنشر في نظام خلفي معيّن، استخدِم
firebase deploy --only apphosting:backendId
مثال على ملف firebase.json
{"apphosting":[{"backendId":"my-backend",// rootDir specifies the directory containing the app to deploy, but the entire// parent directory of firebase.json will be zipped and uploaded to ensure that// dependencies outside of the app directory will be available at build time."rootDir":"./my-app","ignore":["node_modules",".git","firebase-debug.log","firebase-debug.*.log","functions",],},]}
النشر باستخدام Terraform
إذا كنت بحاجة إلى تحكّم أكبر في عملية الإنشاء والبيئة التي تم نشرها، يمكنك النشر باستخدام Terraform. تتيح لك Terraform تحديد موارد App Hosting وإدارتها باستخدام ملفات إعداد تعريفية، كما تتيح لك نشر صورة حاوية مسبقة الإنشاء مباشرةً إلى App Hosting بدلاً من الاعتماد على App Hosting لإنشاء صورة من رمز المصدر.
عند إنشاء تطبيق ويب باستخدام أداة "نماذج التطبيقات الأولية" في Firebase Studio، يمكنك نشره أو نشره على Firebase App Hosting مباشرةً من Firebase Studio. اطّلِع على نشر تطبيقك باستخدام "استضافة التطبيقات".
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\nMost of the time, we recommend using [automatic rollouts](/docs/app-hosting/rollouts) or\n[manually-triggered rollouts](/docs/app-hosting/rollouts#manually-trigger)\nfrom the Firebase console. However, you may have a use for a more customized\ndeployment flow. App Hosting has multiple options for custom deployment.\n\nDeploy from source with the Firebase CLI\n\nThe Firebase CLI lets you push your app's source code and configuration\ndirectly from your local machine to Firebase. This is convenient if you have\nother Firebase deployments (such as security rules or functions) and want to\ndeploy your web app and backend services together with a single CLI command.\n\nOn deployment, App Hosting uploads your source code to a Google Cloud\nStorage bucket, runs your framework build command in Cloud Build, and deploys\nthe final artifacts to Cloud Run and Cloud CDN. App Hosting uses the same\n[build process](/docs/app-hosting/build) for local source deployments as\nGitHub deployments. If you have a `.gitignore` file in your project, the files\nand folders it lists are excluded from your deployment.\n| **Note:** Make sure you have a project on the Blaze Pay-as-you-go plan.\n\nTo deploy your app from local source:\n\n1. Run `firebase init apphosting` in your local project directory.\n2. At the prompt, select **Use an existing project**, and then select the chosen Firebase project.\n3. Select either a new or existing backend to deploy to; this step sets up App\n Hosting deployments for your local directory, prompting you for the\n information App Hosting needs to successfully deploy your app:\n\n 1. The ID of the backend to deploy to\n 2. The region to deploy to (if creating a new backend)\n 3. The path to the root directory of the application code\n\n App Hosting saves your deployment preferences in `firebase.json` (creating\n the file in your local project if it doesn't exist). Once initialization\n completes successfully, you can run `firebase deploy` to deploy your source\n code to App Hosting.\n\nIf you have local source deployments set up for multiple backends (meaning there\nare multiple `backendId` entries in `firebase.json`), `firebase deploy` will\ndeploy to each of those backends. To deploy to a specific backend, use\n`firebase deploy --only apphosting:backendId`\n\nExample firebase.json \n\n {\n \"apphosting\": [\n {\n \"backendId\": \"my-backend\",\n // rootDir specifies the directory containing the app to deploy, but the entire\n // parent directory of firebase.json will be zipped and uploaded to ensure that\n // dependencies outside of the app directory will be available at build time.\n \"rootDir\": \"./my-app\",\n \"ignore\": [\n \"node_modules\",\n \".git\",\n \"firebase-debug.log\",\n \"firebase-debug.*.log\",\n \"functions\",\n ],\n },\n ]\n }\n\nDeploy using Terraform\n\nIf you need greater control over the build process and deployed environment, you\ncan deploy using Terraform. Terraform lets you define and manage your\nApp Hosting resources using declarative configuration files, and provides\nthe ability to deploy your own prebuilt container image directly to\nApp Hosting instead of relying on App Hosting to build from your source\ncode.\n\nIf you're new to Terraform, see\n[Get started with Terraform and Firebase](/docs/projects/terraform/get-started).\nIf you're already familiar with\nTerraform, you can get started with sample configuration files and other\n[App Hosting resources](/docs/projects/terraform/get-started#resources-app-hosting).\n\nDeploy using Firebase Studio\n\nWhen you create a web app with the App Prototyping agent in Firebase Studio,\nyou can publish, or deploy, to Firebase App Hosting directly from\nFirebase Studio. See [Publish your app with App Hosting](/docs/studio/deploy-app#publish)."]]