이 페이지에서는 Cloud Run용 서비스 개발을 시작하기 위해 알아야 할 몇 가지 사항을 설명합니다.
코드 요구사항
서비스를 개발할 때 다음 요구사항을 충족해야 합니다.
서비스는 요청을 리슨해야 합니다.
요청이 전송되는 포트를 구성할 수 있습니다.
Cloud Run 인스턴스 내에서 PORT 환경 변수 값은 항상 요청이 전송되는 포트를 반영합니다.
코드에서는 이 PORT 환경 변수가 있는지 확인해야 하며, 변수가 있으면 이를 리슨하여 이동성을 극대화해야 합니다.
서비스는 스테이트리스(Stateless)여야 하며, 영구 로컬 상태를 사용할 수 없습니다.
서비스가 요청 처리 범위 외부에서 백그라운드 작업을 수행하는 경우 표준 요청 주기 외부에서 CPU가 할당되게 하려면 인스턴스 기반 결제 설정을 사용해야 합니다.
Cloud Run 소스 배포는 여러 언어 런타임을 편리하게 지원하며 각 언어 런타임은 Google Cloud 빌드팩에서 제공하는 컨테이너 기본 이미지를 통해 제공됩니다. 소스 코드가 OCI 준수 이미지에 있는 한 다른 프로그래밍 언어나 프레임워크를 사용할 수도 있습니다.
Gemini Cloud Assist 채팅에서 AI 기반 도움을 받아 애플리케이션을 최적으로 설계할 수 있습니다. Gemini Cloud Assist를 사용하면 Cloud Run에 애플리케이션을 배포하는 데 가장 적합한 구성과 전략을 파악하여 효율적인 리소스 활용과 원활한 운영을 보장할 수 있습니다.
Google Cloud 콘솔에서 Gemini Cloud Assist를 사용하려면 다음을 수행합니다.
[[["이해하기 쉬움","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-07-24(UTC)"],[],[],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)."]]