app.yaml によるアプリの構成

App Engine アプリを構成するには、app.yaml ファイルを使用します。このファイルには、CPU、メモリ、ネットワーク リソース、ディスク リソース、スケーリングをはじめとする、環境変数を含む全般的な設定が含まれています。

app.yaml ファイルの概要

app.yaml ファイルには、バージョンや URL など、Python アプリのランタイム構成を指定できます。このファイルは、特定のサービス バージョンのデプロイ記述子として機能します。

追加サービス用に app.yaml ファイルを作成してデプロイするには、その前に、default サービス用の app.yaml ファイルを作成する必要があります。

次の app.yaml は、最新バージョンの Python を使用するようにアプリを構成する方法を示しています。Python の他のサポート対象バージョンを使用するには、app.yaml ファイルを更新する必要があります。詳細については、Python ランタイムをご覧ください。

# Copyright 2021 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #      http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.  runtime: python env: flex entrypoint: gunicorn -b :$PORT main:app  runtime_config:   operating_system: ubuntu22  # This sample incurs costs to run on the App Engine flexible environment. # The settings below are to reduce costs during testing and are not appropriate # for production use. For more information, see: # https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml manual_scaling:   instances: 1 resources:   cpu: 1   memory_gb: 0.5   disk_size_gb: 10 

アプリのサービスの複雑さによっては、対応する app.yaml ファイルの一部の要素を定義するだけで済む場合もあります。次の例に、フレキシブル環境での簡単な Python アプリで必要になる可能性があるものを示します。

app.yaml ファイルには一意の名前を指定できます。ただし、その場合はデプロイ コマンドでもそのファイル名を指定する必要があります。たとえば、app.yaml ファイルに service-name-app.yaml または app.flexible.yaml という名前を指定した場合は、次のいずれかを使用してアプリをデプロイする必要があります。

gcloud app deploy service-name-app.yaml gcloud app deploy app.flexible.yaml 
アプリで複数のサービスと app.yaml ファイルを構造化する方法については、ウェブサービスの構造化をご覧ください。

すべての構成要素

この構成ファイルでサポートされるすべての要素の一覧については、app.yaml リファレンスをご覧ください。