App Engine 관리자 역할과 서비스 계정 사용자 역할의 상태를 모두 사용 설정됨으로 설정합니다.
배포 구성
Cloud Build를 사용하면 공개적으로 사용 가능한 컨테이너 이미지를 사용하여 작업을 실행할 수 있습니다. Cloud Build 구성 파일의 빌드 step에서 이미지를 지정하면 됩니다.
App Engine은 소스 코드로 이미지를 빌드하고 해당 이미지를 App Engine에 배포하는 gcloud app deploy 명령어를 제공합니다. 구성 파일의 빌드 단계에서 cloud-sdk 이미지를 사용하여 이미지 내 gcloud 명령어를 호출할 수 있습니다.
이 빌드 단계로 전달된 인수는 바로 gcloud CLI로 전달되어 이 이미지에 있는 모든 gcloud 명령어를 실행할 수 있도록 합니다.
cloud-sdk가 호출될 때 bash 도구를 사용하도록 entrypoint 필드를 추가합니다.
args 필드에서 gcloud app deploy 명령어를 호출하고 Cloud Build를 호출할 때 사용할 App Engine에 timeout을 설정합니다. 이는 Cloud Build 빌드 단계와 빌드의 기본 시간 제한이 10분이며 App Engine 배포를 완료하는 데 시간이 더 걸릴 수 있기 때문에 요구됩니다. gcloud app deploy를 완료하는 데 10분 넘게 걸린다면 더 긴 시간 제한을 지정하여 빌드가 시간 초과되지 않도록 합니다.
App Engine 표준 환경 사용 시 시간 초과 오류: App Engine 가변형 환경 사용 시에만 여기서 설명하는 대로 시간 제한을 구성할 수 있습니다. App Engine 표준 환경에서는 빌드 시간 제한을 구성할 수 없습니다. App Engine 표준 환경에서 Cloud Build를 배포에 사용하고 있고 시간 초과 오류로 빌드가 실패할 경우 App Engine 표준 환경 대신에 App Engine 가변형 환경 또는 Cloud Run를 사용하도록 합니다.
[[["이해하기 쉬움","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-04-22(UTC)"],[[["\u003cp\u003eThis guide outlines how to deploy applications to App Engine using Cloud Build, a fully managed, serverless platform.\u003c/p\u003e\n"],["\u003cp\u003eTo deploy an application, you'll need to create a Cloud Build configuration file, which specifies the \u003ccode\u003ecloud-sdk\u003c/code\u003e image and uses the \u003ccode\u003egcloud app deploy\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eThe configuration requires enabling the App Engine API, installing the Google Cloud CLI, having application source code in a repository, and setting the necessary IAM permissions for Cloud Build.\u003c/p\u003e\n"],["\u003cp\u003eContinuous deployment to App Engine can be automated by creating Cloud Build triggers that are activated by code updates in your repository.\u003c/p\u003e\n"],["\u003cp\u003eWhen deploying to the App Engine flexible environment, ensure to set a build timeout in the config file, but note that this isn't configurable in the App Engine standard environment; consider using the flexible environment or Cloud Run if timeout errors occur.\u003c/p\u003e\n"]]],[],null,["# Deploying to App Engine\n\nThis page explains how to deploy applications to App Engine using\nCloud Build. If you're new to Cloud Build, read the\n[quickstarts](/build/docs/quickstarts) and the\n[build configuration overview](/build/docs/build-config) first.\n\nApp Engine is a fully managed, serverless platform for developing and hosting\nweb applications at scale. For more information on App Engine, read the\n[App Engine documentation](/appengine/docs).\n\nBefore you begin\n----------------\n\n- Enable the App Engine API:\n\n [Enable the App Engine API](https://console.cloud.google.com/apis/library/appengine.googleapis.com)\n- To run the `gcloud` commands on this page, install the\n [Google Cloud CLI](/sdk).\n\n- Have your application source code that you want to build and deploy to App Engine\n handy. Your source code needs to be stored in a repository, such as\n Cloud Source Repositories, GitHub, or Bitbucket.\n\n| **Caution:** Effective June 17, 2024, Cloud Source Repositories isn't available\n| to new customers. If your organization hasn't\n| previously used Cloud Source Repositories, you can't enable the API or use\n| Cloud Source Repositories. New projects not connected to an organization can't enable the\n| Cloud Source Repositories API. Organizations that have used Cloud Source Repositories prior to\n| June 17, 2024 are not affected by this change.\n\n### Required IAM permissions\n\n1. In the Google Cloud console, select your project.\n\n2. [Grant](/iam/docs/grant-role-console) the **Cloud Build Service Account**\n role to the App Engine default service account. If service account does not\n appear in the list, locate service account in **Service Accounts** page.\n\n [Go to Service\n Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts)\n3. Grant the **App Engine Admin** role and **Service Account User** to the build\n service account:\n\n 1. In the Google Cloud console, go to the\n *settings* Cloud Build **Permissions** page:\n\n [Go to **Permissions**](https://console.cloud.google.com/cloud-build/settings)\n\n \u003cbr /\u003e\n\n 2. Set the status of the **App Engine Admin** role and the **Service Account User**\n role to **Enabled**.\n\nConfiguring the deployment\n--------------------------\n\nCloud Build lets you use any publicly available container image\nto execute your tasks. You can do this by specifying the image in a build `step`\nin the Cloud Build config file.\n\nApp Engine provides the `gcloud app deploy` command, which builds an image with\nyour source code and deploys that image on App Engine. You can use the [`cloud-sdk`\nimage](https://github.com/GoogleCloudPlatform/cloud-sdk-docker)\nas a build step in your config file to invoke `gcloud` commands within the image.\nArguments passed to this build step are passed to the gcloud CLI directly,\nallowing you to run any `gcloud` command in this image.\n\nTo deploy an application to App Engine, use the following steps:\n\n1. Create a [Cloud Build configuration file](/build/docs/build-config)\n named `cloudbuild.yaml` or `cloudbuild.json`.\n\n | **Note:** Do not store the config file in the same directory as the source code because the gcloud CLI may interpret that you want to deploy the app using Docker via Cloud Build. Instead, store your source in a separate directory and create the config file in the parent directory.\n2. In the config file:\n\n - Add a `name` field to specify the `cloud-sdk` build step.\n - Add an `entrypoint` field to use the `bash` tool when `cloud-sdk` is invoked.\n - In the `args` field, invoke the `gcloud app deploy` command and set a `timeout`\n for [App Engine to use when it invokes Cloud Build](/appengine/docs/standard/nodejs/testing-and-deploying-your-app#deploying_your_application). This is required because Cloud Build\n build steps and builds have a default timeout of 10 minutes and App Engine\n deployments could take longer than that to complete. Specifying a longer timeout\n will make sure that the build doesn't timeout if `gcloud app deploy` takes\n longer than 10 minutes to complete.\n\n **Timeout errors when using the App Engine standard environment** :\n You can configure timeouts as described here only when using the App Engine\n flexible environment. The App Engine standard environment does not allow\n the build timeout to be configured. If you're using Cloud Build\n for deploying on the App Engine standard environment, and your build\n is failing with a timeout error, consider using the App Engine flexible\n environment or [Cloud Run](/build/docs/deploying-builds/deploy-cloud-run)\n instead of the App Engine standard environment.\n - Add a [build `timeout`](/build/docs/build-config#build_steps) value of\n more than 10 minutes.\n\n ### YAML\n\n steps:\n - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'\n entrypoint: 'bash'\n args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']\n timeout: '1600s'\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/google.com/cloudsdktool/cloud-sdk\",\n \"entrypoint\": \"bash\",\n \"args\": [\n \"-c\",\n \"gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy\"\n ]\n }\n ],\n \"timeout\": \"1600s\"\n }\n\n3. Start the build, where \u003cvar translate=\"no\"\u003eSOURCE_DIRECTORY\u003c/var\u003e is the path or URL to the source\n code and \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is one of the [supported build regions](/build/docs/locations)\n to start the build:\n\n gcloud builds submit --region=\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eREGION\u003c/span\u003e\u003c/var\u003e \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSOURCE_DIRECTORY\u003c/span\u003e\u003c/var\u003e\n\nContinuous deployment\n---------------------\n\nYou can automate the deployment of your software to App Engine by creating\nCloud Build triggers. You can configure your triggers to build and\ndeploy images whenever you update your source code.\n\nTo automate your deployment to App Engine:\n\n1. In your repository, add a config file with steps\n to invoke the `gcloud app deploy` command:\n\n ### YAML\n\n steps:\n - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'\n entrypoint: 'bash'\n args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']\n timeout: '1600s'\n\n ### JSON\n\n {\n \"steps\": [\n {\n \"name\": \"gcr.io/google.com/cloudsdktool/cloud-sdk\",\n \"entrypoint\": \"bash\",\n \"args\": [\n \"-c\",\n \"gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy\"\n ]\n }\n ],\n \"timeout\": \"1600s\"\n }\n\n2. Create a build trigger with the config file created in the previous step:\n\n 1. Open the **Triggers** page in the Google Cloud console:\n\n [Open Triggers page](https://console.cloud.google.com/cloud-build/triggers)\n 2. Select your project from the project selector drop-down menu at the top of\n the page.\n\n 3. Click **Open**.\n\n 4. Click **Create trigger**.\n\n On the **Create trigger** page, enter the following settings:\n 1. Enter a name for your trigger.\n\n 2. Select the repository event to start your trigger.\n\n 3. Select the repository that contains your source code and build\n config file.\n\n 4. Specify the regex for the branch or tag name that will start your\n trigger.\n\n 5. **Configuration**: Choose the build config file you created\n previously.\n\n 5. Click **Create** to save your build trigger.\n\nAnytime you push new code to your repository, you will automatically start a\nbuild and deploy on App Engine.\n\nFor more information on creating Cloud Build triggers, see\n[Creating and managing build triggers](/build/docs/automating-builds/create-manage-triggers).\n\nWhat's next\n-----------\n\n- Learn how to [deploy on Cloud Run](/build/docs/deploying-builds/deploy-cloud-run)\n- Learn how to [perform blue/green deployments on Compute Engine](/build/docs/deploying-builds/deploy-compute-engine)\n- Learn how to [deploy on GKE](/build/docs/deploying-builds/deploy-gke)\n- Learn how to [deploy on Cloud Run functions](/build/docs/deploying-builds/deploy-functions)\n- Learn how to [deploy on Firebase](/build/docs/deploying-builds/deploy-firebase)\n- Learn how to [troubleshoot build errors](/build/docs/troubleshooting)."]]