Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Dans cette étape, vous allez créer un service Cloud Run pour déployer l'application à partir du dépôt que vous avez créé à l'étape précédente. Vous allez également configurer un déclencheur Cloud Build automatique afin que l'application soit créée et déployée dans Google Cloud chaque fois que vous envoyez un nouveau commit dans le dépôt.
Créer un service Cloud Run avec un build continu
Dans la console Google Cloud, accédez à Cloud Run.
Cliquez sur Set up with Cloud Build (Effectuer la configuration avec Cloud Build).
Dans la liste Dépôt, sélectionnez le dépôt GitHub dupliqué que vous avez créé pour votre application.
Si votre dépôt ne figure pas dans la liste, cliquez sur Gérer les dépôts connectés.
Lorsque vous effectuez cette étape, procédez comme suit, si vous y êtes invité :
S'authentifier auprès de GitHub
Installez Cloud Build sur votre compte GitHub.
Si vous sélectionnez pour la première fois un dépôt à utiliser avec Cloud Build dans votre projet, cochez la case pour accepter les conditions d'utilisation.
Cliquez sur Suivant.
Dans la section Configuration des services, saisissez les détails suivants :
Branch (Branche) : la branche par défaut est ^main$. Ne modifiez pas ce paramètre.
Type de compilation : cliquez sur Dockerfile.
Emplacement de la source : saisissez les informations suivantes :
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2024/12/20 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2024/12/20 (UTC)."],[],[],null,["# Step 2: Create a Cloud Run service\n\nIn this step, you create a Cloud Run service to deploy the app from the\nrepository that you forked in the previous step. You also set up an automatic\nCloud Build trigger, so that the app is built and deployed to Google Cloud\nwhenever you push a new commit to the repository.\n\nCreate a Cloud Run service with continuous build\n------------------------------------------------\n\n1. In the Google Cloud console, navigate to Cloud Run.\n\n [Go to Cloud Run](https://console.cloud.google.com/run)\n2. Click **Create service**.\n\n3. Select **Continuously deploy from a repository**.\n\n4. Click **Set up with Cloud Build**.\n\n5. In the **Repository** list, select the forked GitHub repository that you created\n for your app.\n\n If your repository isn't listed, click **Manage connected repositories**.\n While completing this step, do the following, if prompted:\n - Authenticate to GitHub.\n\n - Install Cloud Build on your GitHub account.\n\n6. If you're selecting a repository for the first time for use with\n Cloud Build in your project, select the checkbox to agree to the terms of\n use policy.\n\n7. Click **Next**.\n\n8. In the **Build configuration** section, enter the following details:\n\n - **Branch** : The default branch is `^main$`. Don't update this.\n\n - **Build type** : Click **Dockerfile**.\n\n - **Source location**: Enter the following:\n\n /gemini/sample-apps/gemini-streamlit-cloudrun/Dockerfile\n\n9. Click **Save**.\n\n10. On the **Create service** page, enter the following details in the **Configure** section:\n\n - **Service name** : Enter `gemini-streamlit-cloudrun`.\n\n - **Authentication** : Click **Allow unauthenticated invocations**.\n\n - **Service autoscaling** : Set the **Minimum number of instances** to `1`.\n\n11. Click **Container(s), volumes, networking, security**.\n\n12. In the **Revision autoscaling** section, enter the following:\n\n - **Minimum number of instances** : Enter `1`.\n\n - **Maximum number of instances** : Enter `3`.\n\n13. Click **Create**.\n\n14. Optional: To test the app deployment to Cloud Run, do the following: \n\n 1. On the **Services** page in Cloud Run, click the service name.\n\n [Go to the Services page](https://console.cloud.google.com/run)\n 2. On the **Service details** page, click the **URL** displayed next to the service name.\n\nSet up an automatic Cloud Build trigger\n---------------------------------------\n\n1. Navigate to the **Triggers** page in Cloud Build.\n\n [Go to the Triggers page](https://console.cloud.google.com/cloud-build/triggers)\n2. Click the name of your new trigger.\n\n3. Under **Source** , click to expand **Show included and ignored files filters**.\n\n4. In the **Included files filter** box, enter `gemini-streamlit-cloudrun/**`.\n\n5. Click **Save**.\n\n | **Tip:** If you want to manually build the Cloud Run service again, go to the **Triggers** page and click **Run**."]]