הגדרת האפליקציה באמצעות app.yaml

אפליקציית App Engine מוגדרת באמצעות קובץ app.yaml שמכיל משאבי מעבד, זיכרון, רשת ודיסק, קנה מידה והגדרות כלליות אחרות, כולל משתני סביבה.

app.yaml קבצים בקירוב

אתם יכולים לציין את הגדרות זמן הריצה של אפליקציית Python, כולל גרסאות וכתובות URL, בקובץ app.yaml. הקובץ הזה משמש כקובץ תיאור פריסה של גרסה ספציפית של שירות.

קודם צריך ליצור את הקובץ app.yaml לשירות default של האפליקציה, לפני שיוצרים ומפעילים קבצים app.yaml לשירותים נוספים.

בדוגמה הבאה של app.yaml אפשר לראות איך מגדירים את האפליקציה לשימוש בגרסה האחרונה של Python. כדי להשתמש בגרסה נתמכת אחרת של Python, צריך לעדכן את הקובץ app.yaml. מידע נוסף זמין במאמר בנושא Python runtime.

# 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: ubuntu24
  runtime_version: 3.12

# 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.