O App Engine é uma plataforma sem servidor totalmente gerenciada para desenvolver e hospedar aplicativos da Web em escala. Para mais informações sobre o App Engine, leia a documentação do App Engine.
Para executar os comandos gcloud nesta página, instale a
Google Cloud CLI.
Tenha em mãos o código-fonte do aplicativo que você quer criar e implantar no App Engine. Seu código-fonte precisa ser armazenado em um repositório, como
Cloud Source Repositories, GitHub ou Bitbucket.
Permissões do IAM obrigatórias
No console do Google Cloud , selecione seu projeto.
Conceda o papel de conta de serviço do Cloud Build
à conta de serviço padrão do App Engine. Se a conta de serviço não
aparecer na lista, localize-a na página Contas de serviço.
Defina o status do papel Administrador do App Engine e do papel
Usuário da conta de serviço como Ativado.
Como configurar a implantação
O Cloud Build permite que você use qualquer imagem de contêiner disponível publicamente para executar suas tarefas. Para fazer isso, especifique a imagem em uma step de build no arquivo de configuração do Cloud Build.
O App Engine fornece o comando gcloud app deploy, que cria uma imagem com o código-fonte e implanta essa imagem no App Engine. Use a imagem
cloud-sdk
como uma etapa de build no arquivo de configuração para invocar os comandos gcloud na imagem.
Os argumentos transmitidos para essa etapa de build são transmitidos diretamente para a CLI do gcloud,
o que permite executar qualquer comando gcloud nessa imagem.
Para implantar um aplicativo no App Engine, siga estas etapas:
Adicione um campo name para especificar a etapa de build cloud-sdk.
Adicione um campo entrypoint para usar a ferramenta bash quando cloud-sdk for invocado.
No campo args, invoque o comando gcloud app deploy e defina um timeout
para o App Engine usar quando invocar o Cloud Build. Isso é necessário porque as etapas de build do Cloud Build e os builds têm um tempo limite padrão de 10 minutos, enquanto as implantações do
App Engine podem levar mais tempo para concluírem. Especificar um tempo limite maior garante que o tempo limite da build não seja atingido se gcloud app deploy demorar
mais de 10 minutos para ser concluído.
Erros de tempo limite ao usar o ambiente padrão do App Engine: é possível configurar tempos limite conforme descrito aqui ao usar o ambiente flexível do App Engine. O ambiente padrão do App Engine não permite
que o tempo limite da versão seja configurado. Se você estiver usando o Cloud Build para implantar no ambiente padrão do App Engine e o build falhar com um erro de tempo limite, considere o uso do ambiente flexível do App Engine ouCloud Run
em vez do ambiente padrão do App Engine.
Adicione um valor build timeout de
mais de 10 minutos.
{"steps":[{"name":"gcr.io/google.com/cloudsdktool/cloud-sdk","entrypoint":"bash","args":["-c","gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy"]}],"timeout":"1600s"}
Inicie o build, em que SOURCE_DIRECTORY é o caminho ou o URL do código-fonte
e REGION é uma das regiões de build com suporte
para iniciar o build:
gcloudbuildssubmit--region=REGIONSOURCE_DIRECTORY
Implantação contínua
É possível automatizar a implantação de seu software no Google App Engine criando gatilhos do Cloud Build. Configure os acionadores para criar e implantar imagens sempre que atualizar o código-fonte.
Para automatizar sua implantação no App Engine:
No repositório, adicione um arquivo de configuração com etapas para invocar o comando gcloud app deploy:
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-25 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)."]]