「我想在 Cloud Run 上設計 Node.js 應用程式。建議的做法是什麼?需要注意哪些事項?
簡要說明如何將應用程式容器化、建構 Node.js 應用程式,以及部署程序。
「我需要哪些權限才能部署 Cloud Run 應用程式?」
必要權限和角色清單。
「我想使用 Cloud Run 部署三層式網頁應用程式」
設計三層式網頁應用程式的步驟概要。
「如何將 App Engine 應用程式遷移至 Cloud Run」
簡要說明準備 Cloud Run 開發環境的主要步驟,以及這兩項產品之間的一些主要差異。連結至範例教學課程,可用於自訂解決方案,以滿足特定需求。
「What is the gcloud CLI command for updating the min instance setting to 2 for my Cloud Run service 'example-service'」(將 Cloud Run 服務「example-service」的最低執行個體設定更新為 2 的 gcloud CLI 指令為何?)
更新最少執行個體設定的建議 gcloud CLI 指令。
「如何更新 Cloud Run 服務 hello-world 的服務帳戶」
更新服務帳戶的建議 gcloud CLI 指令。
「Show me an example of building a generative AI app on Cloud Run with LangChain」(請提供在 Cloud Run 上使用 LangChain 建構生成式 AI 應用程式的範例)
使用 Cloud Run 和 LangChain 建立範例應用程式的步驟。
"Generate a Terraform config using the google_cloud_run_v2_service resource for a Cloud Run service that sets the billing setting to instance-based billing"
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Developing your service\n\nThis page describes a few things you need to know to get started in developing\na service for Cloud Run.\n\nCode requirements\n-----------------\n\nYou must meet the following requirements when you develop a service:\n\n- The service must listen for requests. You can [configure the port](/run/docs/configuring/services/containers#configure-port) on which requests are sent. Inside Cloud Run instances, the value of the `PORT` environment variable always reflects the port to which requests are sent. Your code should check for the existence of this `PORT` environment variable and if it is present, should listen on it to maximize portability.\n- The service must be *stateless* . It cannot rely on a persistent **local** state.\n- If the service performs background activities outside the scope of request handling it must use the [instance-based billing](/run/docs/configuring/billing-settings#choosing-background-execution) setting in order to have CPU allocated outside of the standard request cycle.\n- If your service uses NFS, it must use the [second generation execution environment](/run/docs/about-execution-environments).\n\nYou can find more details about these constraints in the [Container runtime contract](/run/docs/reference/container-contract).\n\nProgramming language support\n----------------------------\n\nCloud Run source deployment conveniently supports multiple\n[language runtimes](/run/docs/configuring/services/runtime-base-images), each of\nwhich is available through container base images provided by\nGoogle Cloud's buildpacks. You can also use other programming languages or\nframeworks, as long as the source code is in an OCI-compliant image.\n\nThe [build and deploy quickstarts](/run/docs/quickstarts#build-and-deploy-a-web-service)\nprovides samples in many popular languages.\n\nUsing a web server\n------------------\n\nYou can use a web server to listen on the required port, and to process and\nroute incoming requests. For example, Node.js developers can use\n[Express.js](https://expressjs.com/), Python developers can use\n[Flask](http://flask.pocoo.org/), Ruby developers can use\n[Sinatra](http://sinatrarb.com/), and so forth.\n\nContainerizing your code\n------------------------\n\nSee [Containerize your code](/run/docs/building/containerize-your-code) for\ndetails.\n\nDesign Cloud Run apps with Gemini assistance\n--------------------------------------------\n\n\u003cbr /\u003e\n\n|\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nYou can get AI-powered help from\n[Gemini Cloud Assist](/gemini/docs/cloud-assist/overview) chat to\ndesign applications optimally. With Gemini Cloud Assist, you can\ndiscover the most suitable configurations and strategies for deploying your\napplications on Cloud Run, ensuring efficient resource\nutilization and seamless operation.\n\nTo use Gemini Cloud Assist from the Google Cloud console, do\nthe following:\n\n1. [Ensure that Gemini Cloud Assist is set up for your Google Cloud user account and project](/gemini/docs/cloud-assist/set-up-gemini).\n\n2. [Set up your Cloud Run development environment](/run/docs/setup)\n in your Google Cloud project and ensure you have the appropriate\n [deployment permissions](/run/docs/reference/iam/roles#additional-configuration).\n\n3. Go to the Cloud Run page in the Google Cloud console.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n4. In the console toolbar, select a Google Cloud project. Use a project\n associated with a project ID you submitted after you were granted access to\n Gemini Cloud Assist.\n\n5. Click spark\n **Open or close Gemini AI chat**.\n\n The Gemini panel opens.\n6. If necessary, click **Accept** if you agree to the terms.\n\n7. If you have a question about a specific application, provide context by\n going to the page that shows your resource before asking your question. When\n generating a response, Gemini includes information about the\n current console page and project.\n\n8. Enter a prompt in the **Gemini** panel.\n\n The following table provide some example prompts for using\n Gemini Cloud Assist with Cloud Run.\n\nFor more details, see the following resources:\n\n- Learn how to [write better prompts](/gemini/docs/discover/write-prompts).\n- Learn how to use the [Gemini Cloud Assist panel](/gemini/docs/cloud-assist-panel).\n- Read [Use Gemini for AI assistance and development](/gemini/docs/overview).\n- Learn [how Gemini for Google Cloud uses your data](/gemini/docs/discover/data-governance).\n\nWhat's next\n-----------\n\n- Once you have your service code and Dockerfile, you should [build a container image](/run/docs/building/containers) then continue iterating in [local testing](/run/docs/testing/local).\n- If you are migrating an existing web application, see [Migrating Your Service to Cloud Run](/run/docs/migrating).\n- For best practices for designing, implementing, testing, and deploying a Cloud Run service, see the [Development tips](/run/docs/tips)."]]